MySQL数据库设置远程访问权限方法

转自:https://blog.csdn.net/echizao1839/article/details/94380916

注意设置完成后需要执行

flush privileges;

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 'tempuser'@'%';

说明:设置指定用户名为tempuser,密码为空,可访问所有数据库*
 
 4,设置密码访问权限

mysql>grant all privileges on *.* to 'root'@'%' IDENTIFIED BY '8888';

说明:设置指定用户名为tempuser,密码为tempuser,可访问所有数据库*
 
 5,设置指定可访问主机权限

mysql>grant all privileges on *.* to 'tempuser'@'192.168.1.258';

说明:设置指定用户名为tempuser,可访问所有数据库*,只有192.168.1.258这台机器有权限访问

6,给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;
╰︶﹉⋛⋋⊱⋋๑๑⋌⊰⋌⋚﹉︶╯
原文地址:https://www.cnblogs.com/zhangcheng001/p/15079641.html