Mysql開啓遠程訪問權限

 步驟一:登陸數據庫

1 mysql -u root -pvmwaremysql>use mysql; 

 

步驟二: 

一. 方法一更新mysql庫下user表的root條目

  局域網段(特定IP):html

1 mysql>update user set host = '192.168.0.49' where user = 'root'; 

  全網訪問:mysql

1 mysql>update user set host = '%' where user = 'root'; 

二.方法二直接添加一條語句也行

  局域網段(特定IP):sql

1 mysql>insert into user (host,user,password) values('192.168.0.50','root',password('123'));  

   全網訪問:數據庫

1 mysql>insert into user (host,user,password) values('%','root',password('123'));  

三. 方法三

格式以下服務器

1 GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%'IDENTIFIED BY 'mypassword' WITH GRANT OPTION; 

範例:ide

   局域網段(特定IP):spa

1 grant all privileges on *.* to 'root'@'192.168.0.51'identified by '123' with grant option;

  全網訪問:code

1 grant all privileges on *.* to 'root'@'%' identified by '123' with grant option;

  備註:by後面的' '裏的密碼能夠與服務器端的密碼不通,如root在服務器端是123456而by後面的密碼能夠是123。客戶端遠程訪問用密碼123,服務器登陸仍然用123456。htm

 

步驟三:受權刷新(能夠直接重啓服務器)  

1 mysql>FLUSH PRIVILEGES 

 

 來自 <http://www.javashuo.com/article/p-nsoqoriw-br.html> blog

相關文章
相關標籤/搜索