問題:
主機Windows7下的MySQL workbench連接虛擬機MySQL出錯:Host '192.168.145.1' is not allowed to connect to this MySQL server
解決方法:
在虛擬機MySQL中,添加沒有權限連接的host,並授權
GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.145.1' IDENTIFIED BY '密碼' WITH GRANT OPTION;
未授權之前:
mysql> select host,user from user;
+-----------+------+
| host | user |
+-----------+------+
| % | root |
| 127.0.0.1 | root |
| ::1 | root |
+-----------+------+
3 rows in set (0.05 sec)
授權後:
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.145.1' IDENTIFIED BY '123' WITH GRANT OPTION;
Query OK, 0 rows affected (0.07 sec)
mysql> select host,user from user;
+---------------+------+
| host | user |
+---------------+------+
| % | root |
| 127.0.0.1 | root |
| 192.168.145.1 | root |
| ::1 | root |
+---------------+------+
4 rows in set (0.00 sec)