run mysql with docker
1 | docker run -d --name mysql_server \ |
检查是否运行成功:docker ps
然后:
1 | mysql -h0.0.0.0 -P3307 -uroot -proot |
如果报下面错误:
1 | ERROR 2059 (HY000): Authentication plugin 'caching_sha2_password' cannot be loaded: dlopen(/usr/local/mysql/lib/plugin/caching_sha2_password.so, 2): image not found |
则:
1 | docker exec -it mysql_server mysql -uroot -proot |
备注:
默认情况下 MySQL server 只允许本机登录,修改任意IP地址登录:
1 | grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option; |
查看 MySQL server container IP 地址:
1 | docker inspect mysql_server | grep IPAdd |
停止并清理
1 | docker rm -f mysql_server |