mysql實現遠端連線方法
實現遠端連線(授權法)
將host欄位的值改為%就表示在任何客戶端機器上能以root使用者登入到mysql伺服器,建議在開發時設為%。
update user set host = ’%’ where user = ’root’;
將許可權改為ALL PRIVILEGES
mysql> use mysql;
Database changed
mysql> grant all privileges on . to [email protected]’%’ identified by “password”;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> select host,user,password from user;
±-------------±-----±------------------------------------------+
| host | user | password |
±-------------±-----±------------------------------------------+
| localhost | root | *A731AEBFB621E354CD41BAF207D884A609E81F5E |
| 192.168.1.1 | root | *A731AEBFB621E354CD41BAF207D884A609E81F5E |
| % | root | *A731AEBFB621E354CD41BAF207D884A609E81F5E |
±-------------±-----±------------------------------------------+
3 rows in set (0.00 sec)
這樣機器就可以以使用者名稱root密碼root遠端訪問該機器上的MySql.