Mysqladmin:connect to server at ' localhost ' failed error: ' Access denied for user ' root ' @ ' localhost ' (using Password:yes )'

Source: Internet
Author: User
Tags administrator password mysql login

As you forget the MySQL password, forget the password solution

One, MySQL login error
Mysqladmin:connect to server at ' localhost ' failed
Error: ' Access denied for user ' root ' @ ' localhost ' (using Password:yes) '
Unable to change password
with service mysqld stop
Mysqld_safe--skip-grant-tables &
Enter Mysql-uroot-p return Enter
>use MySQL;
> Update user Set Password=password ("Newpass") where user= "root";
Change Password to Newpassord
> Flush Privileges; Update permissions
> Quit quitting
Service mysqld Restart
Mysql-uroot-p New Password entry

===========================================================
Second, forget the login password of local root
Resolution process:
1. Edit/ETC/MY.CNF
Add a row in the [mysqld] configuration section
Skip-grant-tables

2. Restart MySQL after saving
[Email protected] etc]# service mysqld restart
Shutting down MySQL. [OK]
Starting MySQL. [OK]

3. Log in to the database to reset the root password
[[email protected] ~]# mysql-uroot-p MySQL
Enter Password:
Direct Carriage Enter

Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 1
Server Version:5.1.47-log Source Distribution
Copyright (c), Oracle and/or its affiliates. All rights reserved.
This software comes with absolutely NO WARRANTY. This is the free software,
And you is welcome to modify and redistribute it under the GPL v2 license

Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| Information_schema |
| MySQL |
| Test |
+--------------------+
3 Rows in Set (0.00 sec)

Execute the following statement
mysql> Update user set Password=password ("MySQL") where user= ' root ';
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)

4, delete the "skip-grant-tables" line added in the/etc/my.cnf file, restart MySQL;
With the new password will be able to log in normally;

=================================================

Describes a very useful mysql boot parameter ——--Skip-grant-tables. As the name implies, when you start MySQL, do not start the grant-tables, authorization table. What's the use of it? Of course it is useful to forget the administrator password.
Operation Method:
1. Kill the original MySQL:
Rcmysqld stop
Or:
Service Mysqld Stop
Or:
Kill-term mysqld
2. Start MySQL with command line parameters:
/usr/bin/mysqld_safe--skip-grant-tables &
3. Modify the Administrator password:
Use MySQL;
Update user set Password=password (' Yournewpasswordhere ') where user= ' root ';
Flush privileges;
Exit
4. Kill MySQL and restart MySQL

Mysqladmin:connect to server at ' localhost ' failed error: ' Access denied for user ' root ' @ ' localhost ' (using Password:yes )'

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.