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



相关文章

这篇文章主要介绍“hive和mysql的区别是什么”,在日常操作中...
这篇“MySQL数据库如何改名”文章的知识点大部分人都不太理解...
这篇文章主要介绍“mysql版本查询命令是什么”的相关知识,小...
本篇内容介绍了“mysql怎么修改字段的内容”的有关知识,在实...
这篇文章主要讲解了“mysql怎么删除unique约束”,文中的讲解...
今天小编给大家分享一下mysql怎么查询不为空的字段的相关知识...