Home >Database >Mysql Tutorial >How to change mysql password?
Sometimes when we use mysql database, we want to change the default password. How to change it? The following article will introduce it to you, I hope it will be helpful to you.
Method 1: Set the password directly through the mysql console
1. Open the mysql console and enter mysql original Password, press the Enter key to enter. The original password here is empty, as shown in the following figure:
2. Enter the command and press the Enter key
set password =password('123456');
The password has been changed to 123456 successfully. If you want to change the password to something else, just change 123456 to the password you want to set, as shown in the figure below:
Method 2: Change the password by modifying the user table in mysql
1. Open the mysql console, enter the original password, enter "use mysql;", and press Enter to enter the mysql database , as shown in the figure below:
2. Enter the following command and press the Enter key
update user set password=password('123456') where user='root';
to change the original password to 123456, as follows Pictured:
The above is the detailed content of How to change mysql password?. For more information, please follow other related articles on the PHP Chinese website!