MysqlAccessdeniedforuser 'root' @ 'localhost' (usingpassw_MySQL

Source: Internet
Author: User
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 !!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.