mysql容器启动
官方mysql镜像需要设置MYSQL_ROOT_PASSWORD环境变量
docker run -d -p3306:3306 -v [你自己随便指定]:var/lib/mysql --name=mysql -e MYSQL_ROOT_PASSWORD=123456 mysql
# 进入容器
docker exec -it mysql /bin/bash
# 修改密码
mysql> use mysql;
Query OK, 0 rows affected (0.00 sec)
mysql> alter user 'root'@'localhost'IDENTIFIED BY 'MyNewPass';
ERROR 1819 (HY000): Your password does notsatisfy the current policy requirements
mysql> alter user 'root'@'localhost'IDENTIFIED BY 'MyNewPass';
ERROR 1396 (HY000): Operation ALTER USERfailed for 'root'@'localhost'
mysql> alter user'root'@'%' IDENTIFIED BY 'MyNewPass';
##远程访问
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY'123456';