How to retrieve the root password of mysql

Source: Internet
Author: User
This article analyzes several methods for retrieving the root password of mysql. We mainly introduce how to retrieve the root password of mysql using multiple methods. Let's take a look at the tutorial below.

This article analyzes several methods for retrieving the root password of mysql. We mainly introduce how to retrieve the root password of mysql using multiple methods. Let's take a look at the tutorial below.

In windows:

Open the command line window and stop the service:

The Code is as follows:
Net stop mysql

Start mysql, usually to the installation path of mysql, find the mysqld-nt.exe (or mysqld.exe)
Run: mysqld-nt (or mysqld.exe) -- skip-grant-tables. The current window will stop.
In addition, open a command line window and execute mysql. If the command is not displayed, first enter the BIN directory of the MYSQL installation location and then run mysql.

The Code is as follows:
> Use mysql
> Update user set password = password ("new_password") where user = "root ";
> Flush privileges;
> 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

The Code is as follows:
> Use mysql
> Update user set password = password ("new_pass") where user = "root ";
> Flush privileges;

Kill MySQL again and start it in normal mode

Replace with the MYSQL database of the same version: (make sure to back up the database first)
1. reinstall the same version of MySQL on another computer.
2. Delete all contents of datamysql In the MySQL installation directory on the computer with the password forgotten (stop the MySQL service first)
3. Copy all the contents of datamysql In the MySQL installation directory on the newly installed computer to the directory you just deleted.
4. Start the MySQL service.

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.