mysql修改数据库密码

mysql修改数据库密码:
5.7版本数据库在安装时日志中会显示密码
cat /var/log/mysqld.log | grep password

登录时提示修改密码:
mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
简单密码不可以设置:
mysql> alter user ‘root‘@‘localhost‘ identified by ‘123456‘;
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql>

修改数据库密码设置,简单密码也可以用
set global validate_password_policy=0;
set global validate_password_length=1;

设置为简单密码:
alter user ‘root‘@‘localhost‘ identified by ‘111111‘;

密码忘记了:
修改配置文件/etc/my.cnf删除或禁用skip-grant-tables这行。
注:mysql的数据库老版本用参数authentication_string,新版本用参数password
update user set authentication_string=password(‘123456‘) where user=‘root‘;
update user set password=password(‘123456‘) where user=‘root‘;
flush privileges; --刷新系统权限表

用工具登录时报错
ERROR 1130: Host 192.168.3.100 is not allowed to connect to this MySQL server

select Host,User from user where user=‘root‘;
update user set host = ‘%‘ where user =‘root‘;
flush privileges;

再次登录就可以了

相关文章
相关标签/搜索