Fri. Aug 14th, 2020

How to change MySQL password

1 min read
Changing the MySQL password often needed to manage web servers. The MySQL administrator account is root by default, and the password is blank.
mysqladmin command to change the root password
If you have never set a MySQL password, using the root user to connect to the MySQL server does not require a password. To set the root password for the first time, use the following command:
mysqladmin -u root password NEWPASSWORD
If you have already set a password, you need the following command:
mysqladmin -u root -p’oldpassword’ password newpass
Set passwords for other MySQL users
To change the password of an ordinary user, you can use the following command (assuming the user is ddos):
mysqladmin -u ddos -p oldpassword password newpass
Change MySQL root user password using MySQL command
This is another way to change your password. The MySQL server stores the username and password in the user table of the MySQL database. You can use the following methods to directly update the password of ddos user:
mysql -u root -p
mysql> use mysql;
mysql> update user set password=PASSWORD(“NEWPASSWORD”) where User=’ddos’;
mysql> flush privileges;
mysql> quit