The root User Password of MySQL is often easy to forget. It has a mechanism to handle permission errors by skipping the permission check and starting. This document compares Windows and Linu
The root User Password of MySQL is often easy to forget. It has a mechanism to handle permission errors by skipping the permission check and starting. This document compares Windows and Linu
The root User Password of MySQL is often easy to forget. It has a mechanism to handle permission errors by skipping the permission check and starting. This article introduces how to forget or reset a MySQL password in Windows and Linux respectively, hoping to help beginners solve the headache of losing a password.
Reset Password for MySQL for Windows
In general, MySQL in Windows is installed as a service. This document takes Windows 2003 as an example.
1. Stop the MySQL service in the control panel-Administrative Tools-service.
2. Start the MySQL service in security mode (without permission authentication)
"Start Menu"-"run"-Enter "cmd" and press ENTER-cd to the bin directory under the MySQL installation directory, and then execute:
1mysqld-nt.exe -- skip-grant-tables
3. MySQL is running normally. log on to MySQL through PhpMyAdmin. The username is root and the password is empty or contains any other characters;
Reset Password for MySQL for Linux
The principle of password reset in Linux is similar to that in Windows. It uses security mode to skip the permission check and start MySQL.
1. Stop the MySQL service and run the following command:
1 [root @ www ~] #/Etc/init. d/mysql stop
2. Start MySQL in safe mode:
1 [root @ www ~] #/Usr/local/mysql/bin/mysqld_safe -- skip-grant-tables &
3. You can change the password through phpMyAdmin or the command line. The username is root and the password is empty.
Command for password modification:
First, log on to MySQL in command line mode:
1 [root @ www ~] # Mysql-u root-p
Run the following three commands:
> Use mysql;
> Update user set password = password ("new password") where user = "root ";
> Flush privileges;