https://hub.docker.com/_/mysql?tab=description
docker pull mysql
,默认拉取最新版本,指定版本docker pull mysql:5.7
docker run -d --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=1234 -e TZ=Asia/Shanghai mysql
root
账户密码docker ps
Authentication plugin 'caching_sha2_password' cannot be loaded
,需要修改 MySQL 加密方式
docker exec -it mysql bash
mysql -u root -p
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '1234';
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '1234';
FLUSH PRIVILEGES;
,可有可无TZ
,会发现 MySQL 中时间不是北京时间,还需要修改时区,百度 linux 修改时区