Centos系统安装mysql使用navicat连接不上问题

登陆到数据
mysql -uroot -p密码

use mysql;
select host,user,password from user;

可以看到 user 为 root,host 为 localhost 的话,说明 MySQL 只允许本机连接,那么外网,本地软件客户端就无法连接了。

解决方案:

执行如下命令:

update user set host='%' where user ='root';
flush privileges;

mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> update user set host='%' where user ='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

查看是否修改正常:

mysql> select host,user from user;
+-----------+---------------+
| host      | user          |
+-----------+---------------+
| %         | root          |
| localhost | mysql.session |
| localhost | mysql.sys     |
+-----------+---------------+
3 rows in set (0.00 sec)

mysql> 

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容