Windows modifies the MySQL user root password

Source: Internet
Author: User
Tags root access

MySQL is a relational database management system, and MySQL is one of the best RDBMS (relational database Management system, relational data management systems) application software in WEB applications. With PHP and Apache to form a good development environment. Therefore, it is widely used. Many people will encounter MySQL needs to change the password, such as the password is too simple, forget the password and so on. Here I will teach you several ways to modify the MySQL password. Here, for example, change the root password, the operating system is windows.

Note: Modifying MySQL requires root access in MySQL, so the general user cannot change the password unless the administrator is requested.

1. Using the Set password command
    1. Open terminal win+r, input cmd enter can open;
    2. By mysql-u user name-p to specify the root user to log in to MySQL, enter after entering will prompt to enter the password.
    3. Modify the root user password for MySQL, format:mysql> set password for username @localhost = password (' new password '); Example:mysql> set password for [email protected] = password (' root '); The above example changes the user root password to root;
    4. Login again, enter the new password root is OK;

2 with Mysqladmin
    1. Open terminal Win+r input cmd enter to open;
    2. Modify the root user password format for MySQL: mysqladmin-u username-P Old password Password new password example: mysqladmin-uroot-p123; password 123456

The above example will user root the original password 123; Change to a new password 123

Re-login, enter the new password 123 is OK;

3 Editing the user table directly with update
    1. First log in to MySQL.
    2. Connection permissions database: use MySQL;.
    3. Change Password: Update user set Password=password ("123") where user= "root"; (don't forget the last semicolon).
    4. Refresh permissions (required steps): Flush privileges;

Login again, enter the new password root is OK;

4 forgot root password condition
    1. Close the running MySQL service.
    2. Open the DOS window and go to the Mysql\bin directory.
    3. Enter mysqld--skip-grant-tables carriage return. --skip-grant-tables means skipping permission table authentication when starting the MySQL service.
    4. Open a DOS window again (because the DOS window is no longer moving), enter MySQL return, if successful, the MySQL prompt will appear >.
    5. Connection permissions database: use MySQL;.
    6. Change Password: Update user set Password=password ("root") where user= "root"; (Don't forget to add a semicolon at the end).
    7. Refresh permissions (required steps): flush privileges;.
    8. Quit quit.

Restart the MySQL service, using the username root and the new password you just set the root login is OK;

Windows modifies the MySQL user root 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.