MySQ权限控制语句

database

mysql服务器">1.使用root账号登陆到MySQL服务器:

mysql -u root -pmypass;

2.切换到mysql数据库实例:

use mysql;

3.查看用户表:

select host, user, password from user;

4.创建一个只允许从本机登录的用户“yang”,密码为“yangpass”:

create user 'yang'@'localhost' identified by 'yangpass';

5.删除一个名为“yang”的本机登录用户:

drop user 'yang'@'localhost';

6.创建一个允许从任何主机登录的用户“yang”,密码为“yangpass”:

create user 'yang'@'%' identified by 'yangpass';

7.修改允许从任何主机登录的用户“yang”的密码,新密码为“yan”:

set password for 'yang'@'%' = password('yan');

权限">8.向允许从任意主机登录的名为“yang”的用户,授予yang_test的库的所有权限:

grant all privileges on yang_test.* to 'yang'@"%";

9.刷新权限,使权限修改生效:

flush privileges;

10.创建一个允许从任何主机登录的用户“remote”,密码为“app”:

create user 'remote'@'%' identifed by 'app';

11.给“remote”用户授予库“yang_test”上的“t_weapon”表的CRUD权限:

grant select, delete, update, insert on yang_test.t_weapon to 'remote';

12.撤销用户“yang”在“yang_test”库上的所有权限:

revoke all privileges on yang_test.* from 'yang'@'%';

以上是 MySQ权限控制语句 的全部内容, 来源链接: utcz.com/z/532521.html

回到顶部