首页 > 数据库技术 > 详细

mysql修改数据库密码

时间:2019-10-22 19:17:38      阅读:86      评论:0      收藏:0      [点我收藏+]
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;

再次登录就可以了

mysql修改数据库密码

原文:https://blog.51cto.com/7794482/2444570

(1)
(1)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!