4 ways for Mysql to modify the root password under Windows _mysql

Source: Internet
Author: User
Tags flush

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

The first thing to declare is that in most cases, MySQL is required to have root permissions in MySQL, so the general user cannot change the password unless requested by the Administrator.

Method 1: using the Set password command

1, open the terminal win+r input cmd return can be opened;

2, through the Mysql-u username-p to specify the root user login mysql, input back will be prompted to enter the password.

3, modify the MySQL root user password, format:mysql> set password for user name @localhost = password (' new password '); Example:mysql> Set password for root@localhost = password (' Shapolang '); The above example changes the user root password to Shapolang;

Login again, enter new password Shapolang OK;

Method 2: with Mysqladmin

1, open the terminal win+r input cmd return can be opened;

2, modify the MySQL root user password format: mysqladmin-u username-P Old password password new password

Example:mysqladmin-uroot-pshapolang password 123456

The above example changes user root's original password Shapolang to the new password 123456
Login again, enter new password 123456 OK;

Method 3: Edit the user table directly with update

1, first login MySQL.

2, Connection rights database: use MySQL;

3, Change Password: Update user set Password=password ("Shapolang") where user= "root"; (don't forget the last semicolon).

4, refresh the right (must step): Flush privileges;
Login again, enter new password Shapolang OK;

Method 4: Forget root password

1, shut down the running MySQL service.

2, open the DOS window, go to the Mysql\bin directory.

3, input mysqld--skip-grant-tables carriage return. --skip-grant-tables means to skip permission table authentication when starting the MySQL service.

4. Open a DOS window again (because that DOS window is already unable to move), enter MySQL return, if successful, will appear MySQL prompt >.

6, Connection rights database: use MySQL;

7, change the password: Update user set Password=password ("root") where user= "root"; (Don't forget to add the last semicolon).

8, refresh the right (must step): Flush privileges;

9, exit quit.
Restart the MySQL service, using the username root and just set the new password root to log on OK;

Precautions:
MySQL related commands you can either add the directory of the command to the environment variable or go to the directory where the command is being executed.

You can also refer to the following articles for study:

Article One: forget the MySQL root password what to do

Article two: MySQL's root password forget how to modify the root password way

Article three:reset the MySQL root password in the Linux system

The above is the entire content of this article, I hope to help you learn.

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.