Five Ways to force the mysql root Password

Source: Internet
Author: User
If you do not set a new password when installing mysql, the default value is null or 12456. In this case, you can use the command line mysql-uroot-p to log on. However, you do not want to leave the password blank during official use, or it is as simple as 123456. The following are four ways to force the mysql root Password to be modified: the first method is to use upd.

If you do not set a new password when installing mysql, the default value is null or 12456. In this case, you can use the command line mysql-uroot-p to log on. However, you do not want to leave the password blank during official use, or it is as simple as 123456. The following are four ways to force the mysql root Password to be modified: the first method is to use upd.

If you do not set a new password when installing mysql, the default value is null or 12456. In this case, you can use the command line mysql-uroot-p to log on. However, you do not want to leave the password blank during official use, or it is as simple as 123456. The following are four ways to force the mysql root Password Change:
Method 1: Use the update statement to modify
[Root @ localhost ~] # Mysql-uroot-p
Mysql-> user mysql;
Mysql> update user set Password = password ('newpassword') where User = 'root' and Host = 'localhost ';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
Mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
Mysql> quit
Log on again.
Method 2: Use the mysql tool (mysqladmin)
[Root @ localhost ~] # Mysqladmin-u root-poldpassword password 'newpassword ';

Method 3: Use the set statement to modify
[Root @ localhost ~] # Mysql-uroot-p
Mysql-> user mysql;
Mysql> set password for root @ "localhost" = password ("newpassword ");
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
Mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
Mysql> quit
Log on again.
Method 4: Use the grant statement to modify
[Root @ localhost ~] # Mysql-uroot-p
Mysql> user mysql;
Mysql> grant all privileges on *. * to root @ 'localhost' identified by 'newpassword ';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
Mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
Mysql> quit
Log on again.
Method 5: Use phpmyadmin to modify the settings.

I personally tested the above methods. Each method can force the password of the root user of mysql to be modified.

Original article address: five ways to force the mysql root Password to be modified. Thank you for sharing it with the original author.

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.