红联Linux门户
Linux帮助

mysql数据库远程访问设置方法--mysql授权

发布时间:2015-09-18 21:58:48来源:linux网站作者:wych1981

mysql数据库远程访问设置方法。


1、修改localhost
更改 "mysql" 数据库里的 "user" 表里的 "host" 项,从"localhost"改成"%"
mysql>use mysql;
mysql>update user set host = '%' where user = 'root';
mysql>select host, user from user;
mysql>FLUSH PRIVILEGES;


2、指定授权
使用myuser/mypassword从任何主机连接到mysql服务器:
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;

使用myuser/mypassword从ip为192.168.225.166的主机连接到mysql服务器:
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.225.166' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;


3、泛授权
mysql -h localhost -u root
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION; //赋予任何主机上以root身份访问数据的权限
mysql>FLUSH PRIVILEGES;


在Linux中怎样将MySQL迁移到MariaDB上:http://www.linuxdiyf.com/linux/14127.html

在Ubuntu Kylin 15.04中禁止mysql自启:http://www.linuxdiyf.com/linux/12312.html

Ununtu 15.04安装MySql(Django连接Mysql):http://www.linuxdiyf.com/linux/13783.html

Ubuntu15.04下MySQL5.6安装过程:http://www.linuxdiyf.com/linux/13250.html

Ubuntu 15.04安装配置Apache和mysql的方法:http://www.linuxdiyf.com/linux/13074.html