http://www.jb51.net/article/42441.htm

 

MySQL基础知识第一期,如何远程访问MySQL数据库设置权限方法总结,讨论访问单个数据库,全部数据库,指定用户访问,设置访问密码,指定访问主机。

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 'liuhui'@'%' IDENTIFIED BY 'liuhui';

 

说明:设置指定用户名为liuhui,密码为liuhui,可访问所有数据库*

5,设置指定可访问主机权限

 


mysql>grant all privileges on *.* to 'liuhui'@'10.2.1.11';

 

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

还可以设置指定访问某个数据库下的某个数据表,请继续关注MySQL基础知识系列。

相关文章:

  • 2021-07-06
  • 2021-08-19
  • 2022-12-23
  • 2021-09-27
  • 2021-10-25
  • 2021-10-24
  • 2021-12-19
  • 2021-07-02
猜你喜欢
  • 2022-12-23
  • 2021-12-26
  • 2021-12-29
  • 2021-06-07
  • 2022-12-23
  • 2021-12-19
相关资源
相似解决方案