>>> mysql -uroot -p
>>> create user 'username'@'localhost' identified by 'password';
# 1) 授权用户访问所有数据库
>>> grant all privileges on *.* to 'username'@'%' identified by 'password';
# 2) 授权用户访问只可访问特定的数据库中的所有表
>>> grant all privileges on DatabaseName.* to 'username'@'%' identified by 'password';
# 3) 用户只有对特定数据库具有select 、insert 权限
>>> grant select,insert on DatabaseName.* to 'username'@'%' identified by 'password';
# 4) 用户只有对特定数据库中的特定表具有select 、insert 权限
>>> grant select,insert on DatabaseName.tablename to 'username'@'%' identified by 'password';
>>> flush privileges;
网友评论