MySQL several forgot root password retrieve method

Source: Internet
Author: User
Tags flush

Under Windows:

Open the Command Line window to stop the MySQL service:

The code is as follows Copy Code
Net stop MySQL

Start MySQL, general to MySQL installation path, find Mysqld-nt.exe (or Mysqld.exe)
Execution: Mysqld-nt (or Mysqld.exe)--skip-grant-tables the current window will stop.
Also open a command line window, execute MySQL If prompted without this command, first go to MySQL installation location under the Bin directory and then run MySQL

The code is as follows Copy Code
>use MySQL
>update User Set Password=password ("New_password") where user= "root";
>flush privileges;
>exit

With Ctrl+alt+del, find the mysqld-nt process kill it, restart the Mysql-nt service, you can log in with the new password

Under Linux:

If MySQL is running, first kill: Killall-term mysqld.
Start Mysql:bin/safe_mysqld--skip-grant-tables &
You can enter MySQL without the need for a password.
Then it's

The code is as follows Copy Code
>use MySQL
>update User Set Password=password ("New_pass") where user= "root";
>flush privileges;

Re-kill MySQL, start in normal way

Replace with the same version of the MySQL library: (Be sure to back up first)
1, re-install the same version of MySQL on another computer
2, delete the forgotten password of the computer in the MySQL installation directory datamysql all content (to stop the MySQL service first)
3,copy new computer on the MySQL installation directory datamysql all content to just delete the directory
4, start the MySQL service

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.