解决ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)

使用Linux主机将VestaCP面板的MySQL数据库升级到 Mariadb 10.4.6版本。

解决ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)

没想到,输入以下命令 ▼

mysql -uroot -p
  • 输入密码登录mysql

就出现以下错误 ▼

ERROR 1045 (28000): Access denied for user ‘root'@'localhost' (using password: YES)

通常,此错误是由MySQL数据的root用户密码错误引起的,解决方案当然是重置密码。

如何MySQL ERROR 1045 (28000)错误?

第 1 步:使用SSH软件登录后,输入以下命令停止mysql数据库 ▼

systemctl stop mysqld

第 2 步:使用以下命令启动MySQL,并以不检查权限的情况下启动 ▼

mysqld --skip-grant-tables &

此时,报了另一个错误 ▼

[ERROR] Fatal error: Please read “Security” section of the manual to find out how to run mysqld as root!

请SSH输入以下命令 ▼

mysqld --user=root --skip-grant-tables &

第 3 步:SSH登录mysql ▼

mysql -uroot

mysql

第 4 步:更新root密码

Mysql5.7或更高版本 ▼

UPDATE mysql.user SET Password=PASSWORD('123456') where USER='root';

Mysql5.7版本 ▼

UPDATE mysql.user SET authentication_string=PASSWORD('123456') where USER='root';

第 5 步:刷新权限 ▼

flush privileges;

第 6 步:退出mysql ▼ 

exit

quit

第 7 步:使用root用户重新登录mysql ▼

Mysql -uroot -p
  • Enter password:<输入刚改好的密码123456>

希望陈沩亮博客( https://www.chenweiliang.com/ ) 分享的《解决ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)》,对您有帮助。

欢迎分享本文链接:https://www.chenweiliang.com/cwl-1094.html

欢迎加入陈沩亮博客的 Telegram 频道,获取最新更新!

🔔 率先在频道置顶目录获取宝贵的《ChatGPT 内容营销 AI 工具使用指南》!🌟
📚 这份指南蕴含价值巨大,🌟难逢的机遇,切勿错失良机!⏰⌛💨
喜欢就分享和按赞!
您的分享和按赞,是我们持续的动力!

 

发表评论

您的电子邮箱地址不会被公开。 必填项已用 * 标注

滚动到顶部