用户账号管理
mysql查看当前登录的用户
select current_user();
查看用户名,主机名,密码
select user,host,password from mysql.user;
创建一个明码账号,一个密文密码账号
create user '账号名'@'主机名' identified by '123',
'账号名'@'主机名' identified by password
'*23AE809DDACAF96AF0FD78ED04B6A265E05AA257'
删除用户
drop user 用户名@localhost;
修改用户
rename user 'xiangdingjun'@'localhost to 'xiangg'@localhost';
修改用户密码
set password for 'xiangg'@localhost'=password('root');
给用户查询权限
grant select 可以指定列+(cust_id,cust_name)
on mysq_test.customers 指定数据库,数据表
to 'xiangg'@'localhost'; 指定用户
给一个不存在的用户设置select,update权限
grant select,update
on mysql mysql_test.customers
to 'xiang'@'localhost' identified by 'root';
给一个用户设置全部权限,相当root用户
grant all
on mysql_test.*
to 'xiangge'@'localhost';
授予用户创建mysql用户的权限
grant create user
on *.*
to 'xiangg'@'localhost';
权限转移
grant create user
on *.*
to 'xiangg'@'localhost'
with grant option;
回收权限
revoke select
on mysql.customers
from 'xiang'@'localhost';
查看用户权限
show grants for xiangg@'localhost';