Home  >  Article  >  Database  >  How to change mysql password?

How to change mysql password?

青灯夜游
青灯夜游Original
2019-05-20 13:54:1213013browse

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.

How to change mysql password?

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:

How to change mysql password?

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:

How to change mysql password?

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:

How to change mysql password?

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:

How to change mysql password?

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:What does mysqld mean?Next article:What does mysqld mean?