新建普通用户
使用create user创建新用户
create user 'test'@'localhost' identified by '123456';
使用grant创建用户
create user创建的用户没有任何权限,还需要使用grant赋予权限。
grant不仅能创建用户,还可以在创建时同时对用户授权。
grant select,update on *.* to 'test'@'localhost' identified by '123456'; 只有查询和更新权限
grant all on *.* to 'testuser'@'localhost' identified by '123456'; 所有权限
show grants for 'test'@'localshost'; 查看用户拥有的权限
select distinct concat('User: ''',user,'''@''',host,''';') AS query FROM mysql.user; 查看MYSQL数据库中所有用户
select * from mysql.user where user='test' \G