mysql登录报错:ERROR 1045 (28000): Access denied for user (using password: YES)

教程发布:风哥 教程分类:ITPUX技术网 更新日期:2022-02-12 浏览学习:568

MYSQL登录时报错,提示如下:
[root@mysql05 mysql]# /usr/local/mysql/bin/mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

解决方法如下:

1、先停止mysql数据库服务
2、在mysql的目录下找到my.ini,在[mysqld]后面加上skip-grant-tables
3、启动mysql服务,打开Command Line Client以空密码登录
4、退出mysql,并停止服务
5、把my.ini中添加的:skip-grant-tables 去掉
5、再次开启mysql服务,直接回车登录,输入:set password for root@localhost=password('newpwd');
6、退出重新配置!

重新设置密码
[root@mysql05 mysql]# /usr/local/mysql/bin/mysqladmin -u root -p password
Enter password:
New password:
Confirm new password:

[root@mysql05 mysql]# /usr/local/mysql/bin/mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.6.21-ndb-7.3.7-cluster-commercial-advanced MySQL Cluster Server - Advanced Edition (Commercial)
Copyright (c) 2000, 2014, 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> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| ndbinfo |
| performance_schema |
| test |
+--------------------+
5 rows in set (0.01 sec)

本文标签:
网站声明:本文由风哥整理发布,转载请保留此段声明,本站所有内容将不对其使用后果做任何承诺,请读者谨慎使用!
【上一篇】
【下一篇】