command line modify MySQL database password

Source: Internet
Author: User
Tags mysql command line

To modify the MySQL database password via the MySQL command line, here is a detailed description of how to use the MySQL command line to modify the password.

Format: Mysqladmin-u username-P Old password password new password

1. Add a password to root pass123:

First enter directory Mysql\bin under DOS, and then type the following command

Mysqladmin-u Root-password pass123

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

2. Change the root password to pass456.

Mysqladmin-u root-p pass123 Password pass456

The above two are the commands entered on the cmd command line, so the direct carriage return is OK.

the commands in the MySQL environment are described below , with a semicolon as the command terminator at the end of the MySQL command.

3, the command line to modify the root password:

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

After running this line, you will be prompted with the following information:
Query OK, 0 rows Affected (0.00 sec)
Rows matched:2 changed:0 warnings:0

You also need to run the following sentence, otherwise the password will not be modified:

mysql> FLUSH privileges;

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

4. Display the current User:

Mysql> SELECT USER ();

command line modify MySQL database password

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.