docker安裝mysql后,本地navicat連接報錯client does not support authentication
解決辦法:
1. docker ps -a 查找到容器id
2. docker exec -it id /bin/bash 進入mysql容器
3.mysql -u root -proot登陸mysql
此處比較奇怪,我在docker中啟動mysql容器指定密碼是123456但是123456登陸不了,使用密碼root可以登陸
4.use mysql; 進入mysql
5.查詢用戶表信息:
select host,user,authentication_string from user ;
6.更改host為% user為root的用戶的authentication_string
host為%大家可以百度一下,說是方便遠程連接
update user set authentication_string = 'root' where user = 'root' and host = '%';
update user set authentication_string = 'root' where user = 'root' and host = 'localhost';
7.如果還不行使用下面語句:
alter user 'root'@'localhost' identified with mysql_native_password by '123456';
alter user 'root'@'%' identified with mysql_native_password by '123456';
然后navicat登陸就成功啦