1,设置访问单个数据库权限
mysql>grant all privileges on test.* to 'root'@'%';
说明:设置用户名为root,密码为空,可访问数据库test
2,设置访问全部数据库权限
mysql>grant all privileges on *.* to 'root'@'%';
说明:设置用户名为root,密码为空,可访问所有数据库*
3,设置指定用户名访问权限
mysql>grant all privileges on *.* to 'liuhui'@'%';
说明:设置指定用户名为liuhui,密码为空,可访问所有数据库*
4,设置密码访问权限
mysql>grant all privileges on *.* to 'root'@'%' IDENTIFIED BY '88888888';
说明:设置指定用户名为liuhui,密码为liuhui,可访问所有数据库*
5,设置指定可访问主机权限
mysql>grant all privileges on *.* to 'liuhui'@'10.2.1.11';
说明:设置指定用户名为liuhui,可访问所有数据库*,只有10.2.1.11这台机器有权限访问
************************************************************************************************************************************
给Mysql添加远程访问权限的方法
user:myuser pwd:mypassword 从任何主机连接到mysql服务器
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
user:myuser pwd:mypassword 从192.168.1.3连接到mysql服务器
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.3' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
************************************************************************************************************************************
注意了,如果是linux系统防火墙也很重要哦
/* 关闭防火墙 */
service iptables stop
/* 开启防火墙 */
service iptables start
/* 默认关闭防火墙 */
chkconfig iptables off