Docker中安装mysql

时间:2022-04-14 05:33:48

1.docker 中下载 mysql

docker pull mysql

2.启动

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

3.进入容器

docker exec -it mysql bash

4.登录mysql,密码输入123456

mysql -u root -p

5.添加远程登录用户

ALTER USER ‘root‘@‘%‘ IDENTIFIED WITH mysql_native_password BY ‘123456‘;
FLUSH PRIVILEGES;