This article mainly introduces the solution of mysqlAccessdeniedforuser 'root' @ 'localhost' (usingpassword: YES). This article provides detailed solutions and operation notes, for more information about mysql startup, see the following:
[root@www ~]# mysql -u root -pEnter password: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
There are various answers on the internet. The final solution to the problem is summarized as follows. many of them are caused by the failure to set the initial password.
The solution is as follows:
[Root @ www ~] # Service mysqld stop # First disable mysql service Stopping mysqld: [OK] [root @ www ~] # MysqlERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql. sock' (2) [root @ www ~] # Mysql-u root-p # the following problem occurs after the service is disabled: Enter password: ERROR 2002 (HY000 ): can't connect to local MySQL server through socket '/var/lib/mysql. sock '(2) [root @ www ~] # Mysql-u root mysql # enter mysqlReading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with-AWelcome to the MySQL monitor. commands end with; or \ g. your MySQL connection id is 1 Server version: 5.1.73 Source distributionCopyright (c) 2000,201 3, Oracle and/or its affiliates. all rights reserved. oracle is a registered trademark Oracle Corporation and/or itsaffiliates. other names may be trademarks of their respectiveowners. type 'help; 'or' \ H' for help. type '\ C' to clear the current input statement. mysql> update user set password = password ('000000') where user = 'root' and host = 'localhost'; ----> modify the root password Query OK, 1 row affected (0.04 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> flush priviledge; ERROR 1064 (42000): You h Ave an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'priviledge 'at line 1 mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) mysql> \ qBye [root @ www ~] # Mysql-u root-p ------> Enter password again: Welcome to the MySQL monitor. commands end with; or \ g. your MySQL connection id is 2 Server version: 5.1.73 Source distributionCopyright (c) 2000,201 3, Oracle and/or its affiliates. all rights reserved. oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. other names may be trademarks of their respectiveowners. type 'help; 'or' \ H' for help. type '\ C' to clear the current input statement. mysql> \ qBye
This is the end !!