How to use command line to modify MySQL database password

Source: Internet
Author: User

1, to root add a password pass123:

First enter the directory Mysqlbin in DOS, and then type the following command

The code is as follows Copy Code

Mysqladmin-u Root-password pass123

Note: Since Root does not have a password at the beginning, the-p old password can be omitted.

2. Change the password of root to pass456.

The code is as follows Copy Code

Mysqladmin-u root-p pass123 Password pass456

The above two are the commands entered in the CMD command line, so direct return is OK.

The following is a description of the commands in the MySQL environment, with a semicolon as the command terminator at the end of the MySQL command.

3, the command line to modify the root password:

The code is as follows Copy Code

mysql> UPDATE mysql.user SET password=password (' newpassword ') WHERE user= ' root ';

After running this line, you will be prompted with the following information:

The code is as follows Copy Code
Query OK, 0 rows Affected (0.00 sec)
Rows matched:2 changed:0 warnings:0

This time you need to run the following sentence, otherwise the password will not be modified:

The code is as follows Copy Code

mysql> FLUSH privileges;

The following run results represent the successful modification:
Query OK, 0 rows affected (0.16 sec)

4, display the current user:

The code is as follows Copy Code

Mysql> SELECT USER ();

Related Article

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.