windows的navicat连接linux的数据库

在处理Windows连接linux上的数据库问题中,在解决了后windows的navicat连接linux的数据库_第1张图片
····该问题的解决方案连接:https://blog.csdn.net/qq_36171645/article/details/89158446

结果发现自己又出现了windows的navicat连接linux的数据库_第2张图片

于是乎,在查阅各类资料后找到以下解决方案:

1.关闭防火墙

命令:iptables -F

如果已关闭,会出现下面的情况。

在这里插入图片描述

2.授权

mysql数据库默认的user表里会存着user=root的三条记录,如下:

python@ubuntu:~$ mysql -hlocalhost -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 19
Server version: 5.7.17-0ubuntu0.16.04.1 (Ubuntu)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

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>  select user,host from user;
+------------------+------+
| user             | host |
+------------------+------+
| debian-sys-maint | %    |
| mysql.sys        | %    |
| root             | %    |
+------------------+------+
3 rows in set (0.00 sec)

mysql> 

此时,三条记录的host都代表本机,不能远程访问,so需要将host改成%。

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

再去连接mysql,发现还是不行,还需要刷新配置。

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

这样,就可以连接成功了。
在这里插入图片描述

你可能感兴趣的:(MySQL)