Home  >  Article  >  Database  >  MySQL数据库设置远程访问权限方法总结

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

WBOY
WBOYOriginal
2016-06-07 17:51:181271browse

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

1,设置访问单个权限

 代码如下 复制代码

>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基础知识系列。

 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn