Home > Database > Mysql Tutorial > body text

How to change mysql password?

青灯夜游
Release: 2019-05-23 18:54:43
Original
13210 people have browsed it

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');
Copy after login

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';
Copy after login

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!

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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template