How to modify the MySql password if you forget the root password

Source: Internet
Author: User
In linux and windows, the root permission of mysql is unlimited. If you forget the password, you cannot directly modify it, the following describes how to change the password of mysql on Windows root and Linux Root respectively.

In linux and windows, the root permission of mysql is unlimited. If you forget the password, you cannot directly modify it, the following describes how to modify the windows root password and linux root Password for mysql respectively.

Forget the root password in windows


If you forget the root password locally, try the following methods:

Start CMD and stop the mysql service.

The Code is as follows:

Net stop mysql

Go to the bin folder under the mysql installation directory and enter

The Code is as follows:

Mysqld-nt -- skip-grant-tables

Skip password detection

Then a new cmd window is opened.

Enter mysql and press enter to enter mysql as the root user.

The Code is as follows:

Use mysql

Update user set password = password ("new password") where user = "root ";

Flush privileges;

If no error message is displayed, the password can be changed successfully.

Forget the root password in linux

Linux root has the highest power. Once the root password is forgotten or stolen, it is a headache. How can I retrieve the root password? I will summarize it as follows:
(1) Linux system password cracking

1. Press e in the grub option menu to enter the editing mode.
2. (Press e) to edit the kernel line to add/init 1 (or/single)
3. Press B to restart
4. Run the following command

The Code is as follows:

# Vi/etc/passwd enter the passwd file

Delete x from the first line of root: X: 0..., change it to root: 0..., save and exit!

The root password is blank when you enter the system.

Change Password

The Code is as follows:

# Passwd root

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.