Failed to Connectto MySQL at xxx:xx with user root

welcome to my blog

MySQL Workbench connection using the cloud server mysql server error: Failed to Connectto MySQL at xxx: xx with user root

The reason: In the default setting, MySQL only allowed to log in as root localhost

在云服务器上以root身份登录
mysql -u root -p

切换至mysql数据库, 这个数据库是自带的
use mysql;

可以通过命令查看这个数据库中有哪些表
show tables;

从user表中查看Host, User这两列的信息
select Host,User from user;

The last line indicates that only allow localhost log in as root
Here Insert Picture Description

Solution:

The first step, the localhost instead of%, which allows all ip logged in as root (this is actually not appropriate, insecurity), executionupdate user set host = '%' where user ='root';

Here Insert Picture Description

The second step, refresh the configuration to take effect, executeflush privileges;

Here Insert Picture Description
Now we can successfully connect to a MySQL server cloud

Published 599 original articles · won praise 147 · views 210 000 +

Guess you like

Origin blog.csdn.net/littlehaes/article/details/104845118