SET PASSWORD = PASSWORD('xxxxxx');#上面的方式不行就用下面这个
ALTER USER USER() IDENTIFIED BY 'xxxxxx';#若出现ERROR 1819 (HY000): Your password does not satisfy the current policy requirements 说明 你得密码长度和复杂程度不符合要求, 可以设置符合要求的密码,也可以修改密码策略set global validate_password_policy=LOW;set global validate_password_length=6;#设置密码永不过期
ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;#刷新MySQL的系统权限相关表
flush privileges;
根据个人需求,设置数据库用户在所有ip下以及在本地可访问,以下用root用户做演示
grant all privileges on *.* to root@"%" identified by "xxxxxx";
grant all privileges on *.* to root@"localhost" identified by "Passw0rd";
flush privileges;### 若远程工具连接不上,请用 iptables -F 命令来清除防火墙规则
MySql拓展
新建用户
CREATE USER 'username'@'%' IDENTIFIED BY 'xxxxxx';
用户授权
添加用户权限: GRANT ALL ON xiaonuo_vue_pub.* TO 'username'@'%';
撤销用户权限: REVOKE ALL ON xiaonuo_vue_pub.* TO 'username'@'%';
删除用户及权限 :drop user 'username'@'%';#上面的databasename和tablename都可以写成*