MySQL 8.0 添加和修改和删除用户


8.0 修改密码

ALTER USER 'root'@'localhost' IDENTIFIED BY 'passowrd' PASSWORD EXPIRE NEVER; --修改加密规则为永不过期

FLUSH PRIVILEGES; --刷新权限

MySQL8.0 用户授权和之前版本有所区别,低版本的常用授权语句在8.0中会报错:

MySQL8.0版本:

CREATE USER `root`@`localhost` IDENTIFIED BY 'passowrd';GRANT ALL ON *.* TO `root`@`localhost` WITH GRANT OPTION;

MySQL8.0中带过期时间用户的创建:

CREATE USER `root`@`localhost` IDENTIFIED BY 'password' PASSWORD EXPIRE INTERVAL 90 DAY;

GRANT ALL ON *.* TO `root`@`localhost` WITH GRANT OPTION;

创建角色,使用CREATE ROLE:

CREATE ROLE 'developer', 'x_read', 'x_write';

http://www.vmfor.com