docker部署mysql

2021/11/15 19:11:54

本文主要是介绍docker部署mysql,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

1:拉取镜像

docker search mysql
docker pull mysql

2:启动镜像

docker run -p 3306:3306 --restart=always --name mysql -v /usr/local/mysql/conf:/etc/mysql/conf.d -v /usr/local/mysql/logs:/logs -v /usr/local/mysql/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -d mysql

3:配置mysql

docker exec -it mysql容器ID /bin/bash
root@ID:/# mysql -u root -p
mysql> GRANT ALL PRIVILEGES on *.* to root@'%' WITH GRANT OPTION;
mysql> ALTER USER 'root'@'%' IDENTIFIED BY '123456' PASSWORD EXPIRE NEVER;
Query OK, 0 rows affected (0.02 sec)
mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
 Query OK, 0 rows affected (0.01 sec)
mysql>  FLUSH PRIVILEGES;
mysql> exit

 



这篇关于docker部署mysql的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程