目的:想要在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,其中需要注意的