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

相关文章
相关标签/搜索