Solve the problem that MySQL forgets the password

Source: Internet
Author: User

The following articles mainly describe how to solve the problem of forgetting the password of MySQL during actual operations. If you forget the password of MySQL during actual operations, the following articles are meaningful to you. The following describes the main content of the article.

In windows: Open the command line window and stop the mysql service: Net stop mysql

Start mysql, usually to the installation path of mysql, find the mysqld-nt.exe

Run: mysqld-nt -- skip-grant-tables

Open a command line window and execute mysql

 
 
  1. >use mysql  
  2. >update user set passwordpassword=password("new_pass") where user="root";  
  3. >flush privileges;  
  4. >exit 

Use Ctrl + Alt + Del to find the mysqld-nt process and kill it. After restarting the mysql-nt service, you can log on with the new password.

In linux:

If MySQL is running, killall-TERM mysqld is first killed.

Start MySQL: bin/safe_mysqld -- skip-grant-tables &

You can access MySQL without a password.

Then

 
 
  1. >use mysql  
  2. >update user set passwordpassword=password("new_pass") where user="root";  
  3. >flush privileges; 

Kill MySQL again and start MySQL in a normal way. The above content is an introduction to the MySQL password-missing solution. I hope you will get some benefits.

The above content describes how to solve the problem of forgetting the password of MySQL. I hope it will help you in this regard.

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.