docker容器的启用:
查看所有容器:docker ps -a
启用容器:docker start [containerID]
进入容器:docker exec -it [containerID] bash
连接mysql:mysql -u root -p[password]
查看mysql连接状态:telnet [ip] [port]
mysql的密码加密方式>=8.0为caching_sha2_password,<8.0为mysql_native_password;(暂时认知)
当前mysql版本:8.0.23;
远程连接docker中mysql需创建"user"@"%"账号,并配置权限grant all privileges on *.* to "user"@"%";
本地连接docker中mysql需创建"user"@"localhost"账号,并配置权限grant all on *.* to "user"@"localhost";
处理 MySQL 8.0 版本的认证协议问题:
alter user "user"@"%" identified with mysql_native_password;
flush privileges;
或可直接使用root账号登录。
退出mysql:exit
退出docker容器:exit
停用docker容器:docker stop [containerID]
容器自启动:docker update --restart=always [containerID]
关闭容器自启动:docker update --restart=no [containerID]