MySQL Forgotten password solution (Linux and Windows summary) _mysql

Source: Internet
Author: User
Tags flush

When you log in to MySQL, prompt:
ERROR 1045:access denied for user: ' Root@localhost ' (Using password:yes)
Explain the password is incorrect, when you do forget the password, what to do? Do not reinstall, of course, do not need.

Linux or Unix

1. Log in to the system with root or mysqld user
2. Use KILL command to end off MYSQLD process
3. Use the--skip-grant-tables parameter to start MySQL, assuming the MySQL installation directory in/usr/local/mysql/, into the shell.
4. Execute/usr/local/mysql/mysqld_safe--skip-grant-tables & start the MySQL daemon
6. Execute/usr/local/mysql/mysqladmin-u root flush-privileges password "newpassword" to reset password for root user
7. Reboot Mysqld

The 6th step can also directly modify the MySQL user table:

mysql> use MySQL;
mysql> Update user Set Password=password ("NewPassword") where user= "root";
mysql> flush Privileges;

Windows:

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. Assuming the installation directory is d:\mysql\, CMD enters the command line
3. Run d:\mysql\bin\mysqld-nt--skip-grant-tables start MySQL, turn off permissions check
4. Run d:\mysql\bin\mysqladmin-u root flush-privileges password "newpassword" Reset root password
5. Restart the MySQL service

The 4th step can also directly modify the MySQL table, the use of SQL statements with the Linux section, here will not repeat.

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.