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 |