MySql 用户管理及权限管理

一、用户管理

-- 新增用户并限定固定ip连接
create user 'username'@'localhost' identified by 'password';
-- 新增用户并允许所有ip连接(通配符%表示All) create user 'username'@'%' identified by 'password';
-- 删除用户 drop user 'username'@'%';

二、权限管理

-- 查看权限
show grants for 'username';

-- 允许访问所有数据库下的所有表
grant all privileges on *.* to 'username'@'%';

-- 允许访问指定数据库下的所有表
-- grant all privileges on test.* to 'username'@'%' ;

-- 允许访问指定数据库下的指定表
-- grant all privileges on test.test1 to 'username'@'%';

-- 刷新权限
flush privileges;
原文地址:https://www.cnblogs.com/chendongbky/p/11943737.html