Change the root password using the MySQL Change password command

Source: Internet
Author: User
Tags mysql command line

  1. Use the MySQL Change Password command to change the root password.

    There are two ways to enter the MySQL database command line mode:

    Mode one: In the MySQL Start menu contains the MySQL command line client, just click enter root password to enter.

    Mode two: In DOS mode (CMD mode) Navigate to the MySQL installation directory in the subdirectory bin, call Mysql.exe to enter, i.e.

    ======================== the following is the command ===================================

    C:\Program files\mysql\mysql Server 5.1\bin>mysql-u Root

    Enter Password: ******

    ======================== above is the command ===================================

  2. Use the Mysqladmin.exe command to modify the root password of MySQL

    General MySQL root default password is empty, if you have not set the root password before using the Mysqladmin command, you can use the following mysqladmin command to modify the root password

    ======================== the following is the command ===================================

    C:\Program files\mysql\mysql Server 5.1\bin>mysqladmin-u root-p password 123456
    Enter Password
    C:\Program files\mysql\mysql Server 5.1\bin>mysql-u root-p123456

    ======================== above is the command ===================================

  3. As described above using mysqladmin to first modify the root's default password, enter password enter, and then use the Mysql.exe command to enter root and its password to enter the MySQL command line.

    If you have set the root password for MySQL and now need to modify it and go to MySQL command line mode, enter

    ======================== the following is the command ===================================

    C:\Program files\mysql\mysql Server 5.1\bin>mysqladmin-u root-p123456 Password root

    C:\Program files\mysql\mysql Server 5.1\bin>mysql-u root-proot

    ======================== above is the command ===================================

    Can.

  4. Here you use the two commands that come with MySQL Mysqladmin.exe and mysql.exe,mysqladmin change the password command format as follows

    Mysqladmin-u Root-p[oldpass] Password newpass

    Note Oldpass (old password) optional, if the root default password is empty, you do not need to enter, if you need to change the old password, please note that the old password and-p do not have a space, otherwise will be error, the other password and newpass (new password) separated by a space.

    MySQL command is similar to the mysqladmin command format, mainly used to enter the correct user name and password after entering the MySQL command line mode, the format is as follows

    Mysql-u Root-p[password]

    If you do not enter password, the Enter password prompt will appear after the carriage return. If the root password is empty, you do not need to enter password, the Enter password prompt and enter.

  5. At this point, the common MySQL change root password method and command is finished, it should be said that the root password of MySQL is very important, if you forget the root password or stolen, will have serious consequences, it is recommended to rename the root user, Or create a new user in the User Permissions table, giving the usual minimum permissions configuration to ensure the security of the site, and to reset or change the root password in the future.

Change the root password using the MySQL Change password command

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.