Do server operations, modify MySQL password is often required, regular modification of MySQL password is a guarantee of website security. Here is a record of some of the commands for modifying the MySQL password for easy viewing later. Change root password The MySQL administrator account under CentOS is the root user by default and the password is empty. If you have never set a MySQL password, you do not need to enter a password to connect to the MySQL server using the root user. The first time you set the root password you can use the following command: 1mysqladmin-u root password NewPassword If you have already set a password, you need the following command: 1mysqladmin-u root-p ' OldPassword ' Password Newpass For example, the old password is "12345", the new password is "Nowamagic", execute the following command: 1mysqladmin-u root-p ' 12345 ' password ' nowamagic ' Modify other MySQL user's password modify a password for a normal user you can use the following command, such as the user is nmuser:1mysqladmin-u nmuser-p oldpassword password Newpass Another way to change the password is to 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 user nmuser password: 1. Log in to MySQL server: View sourceprint?1mysql-u root-p2. Select MySQL database 1mysql> use Mysql;3. Modify the nmuser password 1mysql> update user set Password=password ("NewPassword") where user= ' Nmuser '; 4. Reset permissions 1mysql> Flush Privileges;2mysql> Quit This method can also be executed with a script (Php,perl) without SSH to the server.
How to modify the MySQL password under CentOS