我们在重装数据时难免会有密码错误或者忘记密码时候
ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: YES)
这种情况明明密码是对的,复制进去还是显示密码错误,这个时候我们不要慌,我们重置密码重新设置就可以了。
- vi /etc/my.cnf
添加
skip-grant-tables
重启mysql跳过密码验证过程
systemctl restart mysqld.service
修改密码
mysql -u root -p
命令然后回车,当需要输入密码时,直接按enter键
mysql> update user set password=password(“新密码”) where user=“root”;
mysql> flush privileges;
mysql> exit
遇到ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘(“000000”) where user=“root”’ at line 1直接 flush privileges;
刷新就可以了