本文主要是介绍CentOS 7.4下解决登录MySQL时,ERROR 1045 (28000): Access denied for user root@localhost (using password: YES,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
[root@VM_0_11_centos ~]# mysql -u root -pEnter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
启动一下mysqld服务试试
Redirecting to /bin/systemctl start mysqld.service
mysql -u root -p[root@VM_0_11_centos ~]# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
发现问题还是没有解决
[root@VM_0_11_centos ~]# service mysqld stopRedirecting to /bin/systemctl stop mysqld.service
先停掉mysqld服务
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[root@VM_0_11_centos ~]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
[1] 2513
既然连不上socket,把networking跳掉,安全模式再登录
[root@VM_0_11_centos ~]# 180330 21:47:46 mysqld_safe Logging to '/var/log/mysqld.log'.
180330 21:47:46 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysqlmysql -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.39 MySQL Community Server (GPL)
Copyright (c) 2000, 2018, 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> use mysql;
Database changed
mysql> UPDATE user SET Password=PASSWORD('???') where USER='???';
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4 Changed: 4 Warnings: 0
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye
去修改一下密码,再刷新
[root@VM_0_11_centos ~]# mysql -u root -p
Enter password:Welcome to the MySQL monitor. Commands end with ; or \g.
再次登录,可以了。
感谢:ktz666
这篇关于CentOS 7.4下解决登录MySQL时,ERROR 1045 (28000): Access denied for user root@localhost (using password: YES的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!