用Docker解决坑爹的环境搭建系列——mysql:5.6

sudo docker pull mysql:5.6
mkdir -p /data/docker/mysql/data /data/docker/mysql/logs /data/docker/mysql/conf
sudo docker run -p 33061:3306 --name mysql -v /data/docker/mysql/conf:/etc/mysql -v /data/docker/mysql/logs:/logs -v /data/docker/mysql/data:/usr/data -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.6
sudo docker start mysql

sudo docker exec -it mysql bash
mysql -u root -p

GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY '新密码' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '新密码' WITH GRANT OPTION;
flush privileges;
exit

cp /usr/my.cnf /etc/mysql/my.cnf
exit

sudo nano /data/docker/mysql/conf/my.cnf

# 增加内容开始
[client]
default-character-set=utf8

[mysql]
default-character-set=utf8

[mysqld]
character-set-server=utf8
# 结束

sudo docker restart mysql

posted @ 2018-11-09 10:04  nicye  阅读(1005)  评论(0编辑  收藏  举报