目的:想要在win10上查看服务器中的mysql数据库
主要遇到的几个问题:
1、ubuntu中的mysql不能远程访问
1、在/etc/mysql/mysql.conf.d/mysql.cnf
中找到bind-address = 127.0.0.1
,将其改成bind-address = 0.0.0.0
。ubuntu默认只允许本地访问mysql,这是因为mysql的bind-address=127.0.0.1,要支持远程连接的话需要把bind-address改成0.0.0.0.
2、重启数据库
service mysql restart
2、连接mysql时报错:message from server: "Host ‘192.168.76.89’ is not allowed to connect to this MySQL server
处理方案:
1、先用localhost方式连接到MySQL数据库,然后使用MySQL自带的数据库mysql;
mysql -u root -p;# 进入数据库
use mysql;
2、执行:select host from user where user = ‘root’; 发现, host的值就是localhost。
将它的值改掉:update user host=’%’ where user = ‘root’;
3、修改完成后,执行:flush privileges;
将修改内容生效,再次配置时,用IP地址或者localhost就能够正常连接到MySQL数据库了。
其操作如下:
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 host from user where user = 'root';
+-----------+
| host |
+-----------+
| localhost |
+-----------+
1 row in set (0.00 sec)
mysql> update user set host='%' where user = 'root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select host from user where user = 'root';
+------+
| host |
+------+
| % |
+------+
1 row in set (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
3、Navicat远程连接数据库
在ubuntu上安装了mysql数据库,希望能够在windows上进行访问,查看数据信息,使用的是Navicat,其中需要注意的