Method One: Use the SQL Statement command update
The cryptographic function PASSWORD(string) that comes with MySQL is required to encrypt a plaintext password, but it cannot be decrypted. Set the password specifically for the Mysql.user (User Rights Table) command as follows:
|
mysql> use mysqldatabase changedmysql> Update user set Password=password (' 123456 ') where user= ' root '; Query OK, 1 row Affected (0.00 sec) Rows matched:1 changed:1 warnings:0 mysql> flush privileges; Query OK, 0 rows affected (0.01 sec) |
Note: After using update, you will need to enter flush privileges further to flush the MySQL System permission related table, otherwise access denied. or restart the MySQL server for the new settings to take effect. If you need to set up MySQL root password is empty, you can not use the password function (it is useless). General format:
|
Update Mysql.user set Password=password (' New password ') where user= ' root '; |
Method Two: Use the Set password command
First make sure to go to MySQL and use the MySQL library, which is the command "using MySQL;" And then run the following command:
|
mysql> set password for ' root ' @ ' localhost ' =password (' Miao '); Query OK, 0 rows Affected (0.00 sec) |
MySQL Modify the command and method to set the root password