docker-compose安装mariadb数据库
环境描述
系统:centos7.8
组件 | 版本 |
---|---|
docker | 20.10.6 |
docker-compose | v2.2.2 |
mariadb | 10.5.10 |
docker安装传送门:https://www.cnblogs.com/inclme/p/15829349.html
docker-compose安装传送门:https://www.cnblogs.com/inclme/p/15829558.html
创建持久化目录
[root@localhost ~]# mkdir -p /root/component/mariadb/{data,conf}
创建mariadb.cnf和my.cnf
[root@localhost ~]# docker run --name=mariadb -d mariadb:10.5.10
Unable to find image 'mariadb:10.5.10' locally
10.5.10: Pulling from library/mariadb
c549ccf8d472: Pull complete
26ea6552a462: Pull complete
329b1f41043f: Pull complete
9f8d09317d80: Pull complete
2bc055a5511d: Pull complete
e989e430508e: Pull complete
201c98fa16f6: Pull complete
cc09fec0bce1: Pull complete
1c9b9043bdda: Pull complete
f0e596ee38c5: Pull complete
Digest: sha256:cf656762c1727a4e08d838aea95973767cb7a9f7151532f38657189ae57051cc
Status: Downloaded newer image for mariadb:10.5.10
72f77bf15b6fcc952a859c51aa6c9374a4301390fe87801c68b6a821ee4878da
[root@localhost ~]# docker cp mariadb:/etc/mysql/mariadb.cnf /root/component/mariadb/conf
[root@localhost conf]# cat my.cnf
# mariaDB configuration file
#
# The MariaDB/MySQL tools read configuration files in the following order:
# 0. "/etc/mysql/my.cnf" symlinks to this file, reason why all the rest is read.
# 1. "/etc/mysql/mariadb.cnf" (this file) to set global defaults,
# 2. "/etc/mysql/conf.d/*.cnf" to set global options.
# 3. "/etc/mysql/mariadb.conf.d/*.cnf" to set MariaDB-only options.
# 4. "~/.my.cnf" to set user-specific options.
#
# If the same option is defined multiple times, the last one will apply.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# If you are new to MariaDB, check out https://mariadb.com/kb/en/basic-mariadb-articles/
#
# This group is read both by the client and the server
# use it for options that affect everything
#
[mysqld]
skip-grant-tables
[client-server]
# Port or socket location where to connect
# port = 3306
socket = /run/mysqld/mysqld.sock
max_connections=1000
# Import all .cnf files from configuration directory
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mariadb.conf.d/
这里我最大连接数修改为1000,默认是100
删除临时mariadb服务
[root@localhost mariadb]# docker rm -f mariadb
mariadb
创建docker-compose文件
[root@localhost mariadb]# cat docker-compose.yml
version: '3'
services:
rebbitmq:
restart: always
image: mariadb:10.5.10
container_name: mariadb
hostname: mariadb
ports:
- 3306:3306
environment:
MYSQL_ROOT_PASSWORD: 123456
TZ: Asia/Shanghai
volumes:
- /etc/localtime:/etc/localtime
- /root/component/mariadb/data:/var/lib/mysql
- /root/component/mariadb/conf/mariadb.cnf:/etc/mysql/mariadb.cnf
- /root/component/mariadb/conf/my.cnf:/etc/mysql/my.cnf
[root@localhost mariadb]# docker-compose up -d
[+] Running 1/1
⠿ Container mariadb Started
使用链接工具测试是否正常并使用sql:show VARIABLES like '%max_connections%'查看配置文件是否生效
推荐这些文章:
MySQL(v5.7)
下载docker镜像
docker pull mysql:5.7
创建并运行docker容器
# 映射宿主机3307端口到容器的3306端口
# 设置mysql的root密码为123456
# 映射宿主机的/home/heruo/mysql/data到容器的/var/lib/mysql
docker run -it --name mysql-test -p 3307:3306\
-e MYSQL_ROOT_PASSWORD=123456 \
-v /home/heruo/mysql/data:/var/lib/mysql \
-d mysql:5.7
d...
通过编译、二进制安装MySQL5.7
下载资源
[root@centos7~]#wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.26-JAVA-glibc2.12-x86_64.tar.gz
创建用户
groupadd mysql
useradd -g mysql -s /sbin/nologin mysql
解压安装
tar zxf mysql-5.7.26-JAVA-glibc2.12-x86_64.tar.gz -C /usr/local
cd /usr/local
ln -s mysql-5.7...
PHP访问数据库出现Access denied for user ‘root’@‘IP地址’
·LAMP环境下
网上的方法测试均无效,之后一次偶然本地登陆出现警告:Warning: World-writable config file '文件路径' is ignored,上网查询后是由于该文件任何人都可以修改,mysql防止有人恶意修改设置,忽略相关配置文件。相关链接
解决方法很简单,去除其他人的写入权限即可,假设报错为:Warning: World-writable config file ’/etc/my.cnf‘ is ignored
更改/etc/my.cnf的权限为644
1 cd /etc
2 sudo chmod 644 my.cnf
chmod:
chmod ...
Mariadb 10.4 root 用户无法使用无密码登录的原因
Mariadb现在是网站建设中使用的主流数据库之一,当前它很多个版本:10.1、10.2、10.3、10.4。
其中10.1和10.2在程序中使用root用户登录连接数据库都没有什么问题。
如果是10.3以上版本的mariadb,其默认仅允许root用户通过命令行的方式登录,所以在程序中用root登录连接数据库的时候,会出现错误。
解决方法就是,新建一个用户,且使其权限与root用户保持一致。
首先,在ssh上用root登录mariadb:
mysql -uroot -p
输入密码成功登录后,建立一个新的用户,并给予最大的权限:
CREATE USER '新用户'@'%' IDENTIFI...
"/etc/docker/daemon.json" E212: Can't open file for writing
出现这个错误的原因是etc目录下没有docker目录,需要先在etc目录下创建docker文件夹,然后再对daemon。json进行修改。
命令参考
[root@localhost ~]# cd /etc
[root@localhost etc]# mkdir docker
[root@localhost etc]# cd docker
[root@localhost docker]# vi daemon.json
越是无知的人越是觉得自己无所不知(之前的自己)
越是学习的人越是觉得自己会的太少了(现在的自己)
共勉
...
Ubuntu 下 Mariadb 数据库的安装和目录迁移
1、简介
本文主要是 Ubuntu 下 Mariadb 数据库的安装和目录迁移,同样适用于 Debian
系统:Ubuntu 20.0.4
Mariadb:10.3.22
注意:文中运行的命令基本上需要管理员权限
2、安装 Mariadb
apt install mariadb-server
3、配置 Mariadb
停止 mariadb 服务,终端输入 systemctl stop mariadb
编辑 /etc/mysql/my.cnf 文件,本质就是旁边的 my.cnf.fallback 文件
具体修改内容可以参考 /etc...
Kali-MariaDB安装使用
据说mysql现在对kali收费,所以得用其他数据库代替,这里倒腾了下mariadb
安装
安装mariadb-client
sudo apt-get install mariadb-client
安装mariadb-server
sudo apt-get install mariadb-server
设置为开机启动服务
systemctl enable mysql
# 停止开机启动可以用如下命令
# systemctl disable mysql
使用
初始化
第一次使用时,需要初始化,此时设置登录数据库的密码
mysql_se...
文章链接:https://www.dianjilingqu.com/51425.html
本文章来源于网络,版权归原作者所有,如果本站文章侵犯了您的权益,请联系我们删除,联系邮箱:saisai#email.cn,感谢支持理解。