MySql创建用户并赋予权限

2018-08-10  本文已影响0人  年少时难免轻狂Ho
CREATE USER 'username'@'%' IDENTIFIED BY 'password';

例子

CREATE USER 'dog'@'localhost' IDENTIFIED BY '123456';
CREATE USER 'pig'@'192.168.1.101_' IDENDIFIED BY '123456';
CREATE USER 'pig'@'%' IDENTIFIED BY '123456';
CREATE USER 'pig'@'%' IDENTIFIED BY '';
CREATE USER 'pig'@'%';

为用户赋予权限

GRANT privileges ON databasename.tablename TO 'username'@'host'

例子

GRANT SELECT, INSERT ON test.user TO 'pig'@'%';
GRANT ALL ON *.* TO 'pig'@'%';
GRANT ALL ON maindataplus.* TO 'pig'@'%';

刷新权限

FLUSH PRIVILEGES;

删除用户

DROP USER 'username'@'host';
上一篇 下一篇

猜你喜欢

热点阅读