Docker 快速部署 mysql,从此学习demo不再为环境困扰

拉取 mysql 镜像

docker pull mysql:latest

启动 mysql

docker run -itd --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql

进入 mysql

docker exec -it mysql bash

连接mysql

mysql -h localhost -u root -p

设置mysql的远程连接

1 use mysql;
2 ALTER user 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
3 FLUSH PRIVILEGES;

如果远程连接不上,建议重启一下容器再试

docker restart CONTAINER ID

----------------------------- 备忘记录,快速上手操作

上一篇:09 spark连接mysql数据库


下一篇:【MySQL故障处理】[ERROR] Failed to open log (file '/data/mysql_3306/logs/mysql_bin.000012', errn