美文网首页
MySql创建用户并赋予权限

MySql创建用户并赋予权限

作者: 年少时难免轻狂Ho | 来源:发表于2018-08-10 17:59 被阅读0次
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';

相关文章

网友评论

      本文标题:MySql创建用户并赋予权限

      本文链接:https://www.haomeiwen.com/subject/aejlbftx.html