How to change the MySQL database password?

黄舟
Release: 2017-08-01 11:06:19
Original
3015 people have browsed it

Mysql is a relational database. It is often used in daily work. But what should we do when the database is unavailable for a long time or the database password is forgotten under other circumstances?

Here are two solutions for you, guaranteed to better solve your problem. (The following is an example of changing the password under ubuntu)

How to change the MySQL database password?

1. First, enter the console page (enter through ctrl+alt+t under ubuntu, windows Open through the start menu under the system)

How to change the MySQL database password?

2. Enter "mysqld_safe --skip-grant-tablesmysql -u root mysql" in the console, Click on retracement.

How to change the MySQL database password?

3. After that, enter "UPDATE user SET password=PASSWORD("password") WHERE user='root';" (password is New password, you can change it to any password you want to set), the password set in the picture below is 123456.

How to change the MySQL database password?

4. After that, enter "FLUSH PRIVILEGES;" to refresh the update. finished editing.

How to change the MySQL database password?

5. After inputting, click on the backtest, and you will see the information as shown below, indicating that the refresh is successful.

How to change the MySQL database password?

6. Finally, you can use mysql, and the password has been changed to the password you set.

How to change the MySQL database password?

When you know the password/Step 2

1. The following is when you know the password, when you know the password , first enter mysql -u root -p, and then enter the database password to enter the database.

Then enter "use mysql;".

How to change the MySQL database password?

2. Then enter "UPDATE user SET Password = PASSWORD('password') WHERE user = 'root';" (password is the new password, change the password as shown below is 123456)

How to change the MySQL database password?

3. After that, enter "FLUSH PRIVILEGES;" to refresh the update. finished editing.

How to change the MySQL database password?

#4. Finally, when you enter mysql again, you need to enter the newly set password. At the same time, you can see the data under the current database through the (show tables;) command. table information.

How to change the MySQL database password?

Notes

1. All instructions under the database need to be marked with;.

2. If you think this experience is helpful to you, please click the [Thumbs Up] on the left to support it! If you want to browse at any time in the future, please click [Collect] on the right. If you think this experience If it helps you, please click the double arrows at the bottom right of the page to share

The above is the detailed content of How to change the MySQL database password?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!