YangSunshine 2019-06-26
CREATE USER 'username'@'host' 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 privileges ON databasename.tablename TO 'username'@'host' WITH GRANT OPTION;
SET PASSWORD FOR 'username'@'host' = PASSWORD('newpassword');
例子:
SET PASSWORD FOR 'pig'@'%' = PASSWORD("123456");
REVOKE privilege ON databasename.tablename FROM 'username'@'host';
五.删除用户
DROP USER 'username'@'host';