微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

ERROR 1045 (28000): Access denied for user

mysqladmin本地登陆报错 ERROR 1045 (28000): Access denied for user 'root'@'localhost' 的解决方案如下:

MysqLadmin -u root password xxxx


#1.停止MysqL数据库
/etc/init.d/MysqL stop 
#2.执行如下命令
MysqLd_safe --user=MysqL --skip-grant-tables --skip-networking & 
#3.使用root登录MysqL数据库
MysqL -u root MysqL 
#4.更新root密码
MysqL> UPDATE user SET Password=PASSWORD('MysqL') where USER='root';
MysqL>grant all on *.* to root@'%' identified by "MysqL";
#5.刷新权限 
MysqL> FLUSH PRIVILEGES; 
#6.退出MysqL
MysqL> quit 
#7.重启MysqL
/etc/init.d/MysqL restart 
#8.使用root用户重新登录MysqL
MysqL -uroot -p 
Enter password: <输入新设的密码newpassword>






操作日志如下:
[root@MysqLdb1 ~]# /etc/init.d/MysqL stop
Shutting down MysqL..[  OK  ]
[root@MysqLdb1 ~]# 
[root@MysqLdb1 ~]# MysqLd_safe --user=MysqL --skip-grant-tables --skip-networking & 
[1] 7384
[root@MysqLdb1 ~]# 160606 15:23:44 MysqLd_safe Logging to '/var/lib/MysqL/MysqLdb1.err'.
160606 15:23:44 MysqLd_safe Starting MysqLd daemon with databases from /var/lib/MysqL


[root@MysqLdb1 ~]# MysqL -u root MysqL 
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A


Welcome to the MysqL monitor.  Commands end with ; or \g.
Your MysqL connection id is 1
Server version: 5.6.31 MysqL Community Server (GPL)


copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.


Oracle is a registered Trademark of Oracle Corporation and/or its
affiliates. Other names may be Trademarks of their respective
owners.


Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


MysqL> UPDATE user SET Password=PASSWORD('xxxxx') where USER='root';
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4  Changed: 4  Warnings: 0

MysqL> grant all on *.* to root@'%' identified by "xxxxxx";
Query OK, 0 rows affected (0.00 sec)
 
MysqL> FLUSH PRIVILEGES; 
Query OK, 0 rows affected (0.00 sec)


MysqL> quit
Bye

[root@MysqLdb1 ~]# /etc/init.d/MysqL restart 
Shutting down MysqL..160606 15:25:46 MysqLd_safe MysqLd from pid file /var/lib/MysqL/MysqLdb1.pid ended
[  OK  ]
Starting MysqL.[  OK  ]
[1]+  Done                    MysqLd_safe --user=MysqL --skip-grant-tables --skip-networking
[root@MysqLdb1 ~]# MysqL -uroot -p 
Enter password: 
Welcome to the MysqL monitor.  Commands end with ; or \g.
Your MysqL connection id is 1
Server version: 5.6.31


copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.


Oracle is a registered Trademark of Oracle Corporation and/or its
affiliates. Other names may be Trademarks of their respective
owners.


Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


MysqL
MysqL



版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐