当前位置:Gxlcms > 数据库问题 > mysql修改数据库密码

mysql修改数据库密码

时间:2021-07-01 10:21:17 帮助过:5人阅读

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修改数据库密码

标签:tables   文件   root   密码   data   rem   禁用   lob   tin   

人气教程排行