3.docker安装mysql
2020-03-09 本文已影响0人
_zt_d58b
1.新建目录
mkdir /data/mysql/config
mkdir /data/mysql/data
2.配置文件
vim my.conf
[mysqld]
user=mysql
character-set-server=utf8
default_authentication_plugin=mysql_native_password
log-bin=/var/lib/mysql/mysql-bin
expire-logs-days=7
max-binlog-size=500M
server-id=1
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
3.启动容器
···
docker run -d -p 3306:3306 --restart always --privileged=true --name mysql -e MYSQL_ROOT_PASSWORD=123456 -v /data/mysql/config/my.conf:/etc/my.cnf -v=/data/mysql/data:/var/lib/mysql mysql:5.6
···
4.修改登录
···
docker exec -it mysql /bin/bash
mysql -u root -p
password: root
进入mysql中运行一下命令
use mysql;
GRANT ALL PRIVILEGES ON . TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
flush privileges;
···