这里写自定义目录标题
Linux下安装MySQL5.7密码错误BUG
启动MySQL :
sudo systemctl start mysqld
查看MySQL密码:
sudo cat /var/log/mysqld.log | grep password
用查到的密码去进入 mysql -uroot -p’password’
密码错误:Access denied for user 'root'@'localhost' (using password:YES)
密码失效:Access denied for user 'root'@'localhost' (using password:NO)
如果密码错误:
vi /etc/my.cnf
在[mysqld]下面添加一条命令:
skip-grant-tables
wq保存退出
mysql -uroot进入mysql中
set global validate_password_length=4;
set global validate_password_policy=0;
use mysql;
update user set authentication_string=password('填入新密码') where user='root';
update user set host="%" where user="root";
flush privileges;
exit;
然后把/etc/my.cnf中刚才加的命令注释掉
重启mysql
sudo systemctl stop mysqld
sudo systemctl start mysqld
mysql -uroot -p’新密码’ --如果报错或者密码有问题可以去修改一下密码生效
update mysql.user set password_expired='N';--先进入mysql然后设置密码生效