mysql docker设置root远程登录

进入容器输入:

cd /etc/mysql
vi my.cnf

在结尾添加:

skip-grant-tables

保存退出。
重启进入容器输入mysql,然后再刷新一下权限

flush privileges;

接着依次:

use mysql;
select host, user, authentication_string, plugin from user;
update user set host='%' where user='root';
FLUSH PRIVILEGES;

远程登录就完成了,用Navicat之类的工具还需要改下加密规则。

MySQL8.0之前的版本密码加密规则:mysql_native_password
MySQL8.0密码加密规则:caching_sha2_password

输入:

ALTER USER 'root'@'localhost' IDENTIFIED BY '密码' PASSWORD EXPIRE NEVER;
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '密码';
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '密码';

如果报ERROR 1290 (HY000): The MySQL server is running with the –skip-grant-tables错误就先输入: flush privileges;

© 版权声明
THE END
喜欢就支持一下吧
点赞13 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容