用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
相關文章
相關標籤/搜索