MySQL基础

cmd登录root用户

查看所有用户及host:

use mysql;
select user,host from user;

查看所有数据库:

show databases ;

创建用户:create user '用户名'@‘host’  identified by '密码'

create user 'test'@'localhost' identified by '123456';

刷新权限:

flush privileges ;

授权给用户:grant 权限(增删改查)  on 数据库名.*  '用户名'@'host'

grant insert,update,select,delete on test.* to 'test'@'localhost';

取消授权:revoke 权限(增删改查)  on 数据库名.* ‘用户名’@'host'

revoke select on test.* from 'test'@'localhost';

切换数据库:use 数据库名

use hello;

查看所有表:

show tables ;

修改用户host:update user set host='i新的d' where user='用户名'   ps:%表示所有,在此语句中表示不对用户登录时的id作限制

update user set host='%' where user='test';

查看用户权限:show grants for '用户名'@‘host’;

show grants for 'test'@'localhost';

删除用户:drop user '用户名'@‘host’;

drop user 'test'@'localhost';
原文地址:https://www.cnblogs.com/qc-wh/p/11430070.html