How to handle forgetting the mysql password (linux, windows) This section describes how to handle the mysql password. It mainly describes how to retrieve the password in different operating systems, such as linux and windows.
How to deal with password in the forgot mysql tutorial (linux, windows)
This section describes how to handle mysql passwords. It mainly describes how to retrieve passwords in different operating systems, such as linux and windows.
#/Etc/init. d/mysql stop
# Mysqld_safe -- user = mysql -- skip-grant-tables -- skip-networking &
# Mysql-u root mysql
Mysql> update user set password = password ('newpassword') where user = 'root ';
Mysql> flush privileges;
Mysql> quit
#/Etc/init. d/mysql restart
# Mysql-uroot-p
Enter password: <enter the new password newpassword>
Mysql>
How to deal with windows forgot mysql password
1. Edit the MySQL configuration file:
In windows: % MySQL_installdir % my. ini // In the MySQL installation directory, my. ini is the configuration file of MySQL.
In linux:/etc/my. cnf
Add the following line in the [MySQLd] configuration section:
Skip-grant-tables
Save and exit editing.
2. Restart the MySQL service.
In windows:
Net stop MySQL
Net start MySQL
In linux:
/Etc/init. d/MySQLd restart
3. Set a new ROOT password.
Then run the following command in the command line:
MySQL-uroot-p
Press enter without a password to go to the database tutorial.
Go to the MYSQL table
Use mysql;
Run the following statement to update the root password to 123456:
Update user set password = PASSWORD ("123456") where user = 'root ';
Quit exit MySQL
4. Restore the configuration file and restart the service.
Then, modify the MySQL configuration file and delete the row that you just added.
Restart the MySQL service again. The password has been changed.