Problem docker After installing mysql 8, can not be accessed remotely

1. First check your server if there is a security group or firewall restrictions preventing access

2. Check the docker container mysql start time is bound to the port, here is my 3306

3. Check whether mysql user has access rights

 docker exec -it name of your container bash

After entering the console mysql -uroot -p and enter your root password to enter the mysql;

use mysql;

select user,host from user;

See if your host is the root of the% default only localhost is the only native access, if not then create a

create user 'root'@'%' IDENTIFIED BY 'pwd123456';

4. At this time you may be also given as follows, to change the password mode, because the default is to use caching_sha2_password after mysql 8.0

 ALTER USER'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456'; 
//这里的123456是密码 建议复杂一点

Note: You can not use direct update user set plugin = 'mysql_native_password' where user = 'root', in this way, with a fourth in the statement, I have here is such a change, and then tried many times or not connected

 

Thank you for reading! If there are any errors in the article, or if you have a better understanding and suggestions, please contact me!

Published 29 original articles · won praise 18 · views 30000 +

Guess you like

Origin blog.csdn.net/Baby_lucy/article/details/103906466