How to change the root password in mysql

Source: Internet
Author: User

This article will share with you a detailed explanation of the command for modifying the root password in mysql. If you need to know how to change the root password, refer to it.

MYSQL command to change the root password

Switch to the mysql installation directory under cmd

Example

D:/mysql/bin

Prerequisites: the mysql root Password is empty.

Enter mysql-u root mysql

Mysql> enter update user set password = password ('new password') where user = 'root ';

Echo

Query OK, 0 rows affected (0.00 sec)

Rows matched: 2 Changed: 0 Warnings: 0

Mysql> Status, enter flush privileges;

Echo

Query OK, 0 rows affected (0.00 sec)

Mysql> enter quit

Exit SQL

Note that a semicolon ";" must be added after each command.

Mysql started to execute this command

The second command updates the database of the mysql system that has been loaded into the memory.

Restart mysql.

After the root password is updated, the method for connecting to MySQL is as follows:

New mysql-uroot-p Password

MYSQL command to change the root password

Switch to the mysql installation directory under cmd

Example

D:/mysql/bin

Prerequisites: the mysql root Password is empty.

Enter mysql-u root mysql

Mysql> enter update user set password = password ('new password') where user = 'root ';

Echo

Query OK, 0 rows affected (0.00 sec)

Rows matched: 2 Changed: 0 Warnings: 0

Mysql> Status, enter flush privileges;

Echo

Query OK, 0 rows affected (0.00 sec)

Mysql> enter quit

Exit SQL

Note that a semicolon ";" must be added after each command.

Mysql started to execute this command

The second command updates the database of the mysql system that has been loaded into the memory.

Restart mysql.

After the root password is updated, the method for connecting to MySQL is as follows:

New mysql-uroot-p Password


TIPS: If you think it is too complicated to change the root password in command mode, you can use phpmyadmin to change the root password. This is very simple, however, after changing the password, phpmyadmin needs to reconfigure the user's logon 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.