mysql8添加新用户并授权
-- mysql8添加新用户并授权
create user '用户名'@'localhost' identified by '新密码';
grant all privileges on 数据库名.表名(*代表所有表) to '用户名'@'localhost' with grant option;
flush privileges;
-- mysql8默认的密码策略可能会影响登陆验证,下面是刷新为原来的
ALTER USER '用户名'@'localhost' IDENTIFIED WITH mysql_native_password BY '密码'; #修改加密规则
ALTER USER '用户名'@'localhost' IDENTIFIED BY '密码' PASSWORD EXPIRE NEVER; #更新一下用户的密码且不过期
FLUSH PRIVILEGES; #刷新权限