MySQL Access denied for user root@localhost

Source: Internet
Author: User
Tags flush


Found a solution from the Internet, here to record:

1. Admin login system, stop MySQL service or end mysqld-nt process;
2. Go to the command line and come to MySQL's installation directory. Suppose the installation directory is d:/mysql/, cmd enter the command line;
3. Run D:/program files/mysql/mysql Server 5.5/bin/mysqld-nt--skip-grant-tables start MySQL, turn off the check of permissions;
4. Run D:/program files/mysql/mysql Server 5.5/bin/mysqladmin-u root flush-privileges password "newpassword" to reset the root password;
5. Restart the MySQL service;

Click here to find that the problem cannot be resolved, and then search

Now I found the solution, as follows


Mysql> INSERT into Mysql.user (Host,user,password) VALUES

('% ', ' system ', PASSWORD (' manager '));

Mysql> FLUSH Privileges

Specifically, this is adding a user named system with a password of manager. Note that you want to use the password function, and then use the flush

Privileges to perform the confirmation.

Finally did not solve, and found a solution

The workaround is to reset the root password by following the steps in the Windows platform:
1, as a system administrator login to the system;
2, if the MySQL server is running, stop it.
If it is a server running as a Windows service, go to Service Manager: Start menu-> Control Panel-> management tools-> Services
If the server is not running as a service, you may need to use Task Manager to force it to stop.
3. Create 1 text files and place the following commands on a single line:
SET PASSWORD for ' root ' @ ' localhost ' = PASSWORD (' Mynewpassword ');
Save the file with any name. In this case, the file is C:/mysql-init.txt.
4, enter the DOS command prompt: Start menu-> run-> cmd
Assume that you have installed MySQL to C:/mysql. If you have MySQL installed in another location, please adjust the following command accordingly.
At the DOS command prompt, execute the command:
C:/> c:/mysql/bin/mysqld-nt--init-file=c:/mysql-init.txt
When the server starts, executes the contents of the file named by the "--init-file" option, which reads the SQL command from the specified file at startup, and changes the root user password. After the server has successfully started, you should delete the C:/mysql-init.txt.
5, stop the MySQL server, and then restart it in normal mode. If you run the server as a service, you should start it from the Windows Services window. If you start the server manually, you can use the command as you normally would.
You should be able to connect using the new password.

All the evils of Baidu find methods are not used, I do not find a direct reinstallation of the MySQL database to solve this problem, summed up in Baidu found almost all the same solution can not solve the problem, I hope Baidu will have a good deal.

Related Article

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.