mysql新建用户并授权权限

mysql新建用户并授权权限

#@修改用户密码

UPDATE user SET Password = PASSWORD('newpass') WHERE user = 'root';
FLUSH PRIVILEGES;

#创建用户:

CREATE USER 'username'@'host' IDENTIFIED BY 'password';

#授权:

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

例子:

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

GRANT ALL ON pdweb.* TO 'pdwebcn'@'%';

四.撤销用户权限

命令:

REVOKE privilege ON databasename.tablename FROM 'username'@'host';

说明: privilege, databasename, tablename – 同授权部分.

五.删除用户

命令:

DROP USER 'username'@'host';

留下回复