MySQL Modify the command and method to set the root password

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.