MySQL Database modification root Password method introduction

Source: Internet
Author: User
Tags flush mysql command line phpmyadmin

Method one, with Mysqladmin


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

The code is as follows Copy Code

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 between the space, otherwise it will error, and password and newpass (new password) between the space separated.

The code is as follows Copy Code

Mysql-u Root

mysql> SET PASSWORD for ' root ' @ ' localhost ' = PASSWORD (' Newpass ');

Mode two: In DOS mode (CMD mode) to navigate to the MySQL installation directory in the subdirectory bin, call Mysql.exe Enter, that is

The code is as follows Copy Code

C:Program filesmysqlmysql Server 5.1bin>mysql-u root-p

Enter Password: Hu Jintao

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

The general MySQL root default password is null, if you have not previously set the root password to use the Mysqladmin command, you can use the following mysqladmin command to modify the root password

The code is as follows Copy Code

C:Program filesmysqlmysql Server 5.1bin>mysqladmin-u root-p password 123456

Enter Password:

C:Program filesmysqlmysql Server 5.1bin>mysql-u root-p123456

As mentioned earlier, when using mysqladmin to first modify the default password for root, enter password enter, and then use the Mysql.exe command to type root and its password to enter the MySQL command line.


If Root has already set the password, use the following method

The code is as follows Copy Code

mysqladmin-u root password Oldpass "Newpass"

Method 3: Edit the user table directly with update

The code is as follows Copy Code

Mysql-u Root

mysql> use MySQL;

mysql> UPDATE user SET Password = Password (' newpass ') WHERE user = ' root ';

mysql> FLUSH privileges;

When you lose the root password, you can do this.

The code is as follows Copy Code

Mysqld_safe--skip-grant-tables&

Mysql-u Root MySQL

mysql> UPDATE user SET Password=password ("New password") WHERE user= ' root ';

mysql> FLUSH privileges;

Use phpMyAdmin to change the MySQL root password is very convenient, installation configuration good phpmyadmin, first login admin interface, click on the right to modify the password link, enter you want to modify the MySQL root new password, the last click to execute can

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.