Many people use phpmyadmin or the command line to change the root password of mysql, and after restarting, they find that mysql login error is found, why is this?
To change the password of mysql root, you need to change the password of root in the mysql database in the mysql software, and also change it in the configuration file.
And the modification in the database is not only to modify one line of data, so do not modify it manually, but use commands to modify.
First, log in to phpmyadmin with the root account, then click on the left side to enter the mysql database, and click "mysql" at the top to enter the sql input interface. Enter the following command:
update user set password=password('123456') where User='root'
Among them, 123456 is the password you want to change, so remember not to change the password directly in the database.
Then click "Execute" in the lower right corner and see "Affected x lines", which means that the modification is successful.
Changing the password is basically done here, but there will be a follow-up problem, the database password is changed, and when you exit phpMyAdmin and come in again, you will find that you can't connect to the database.
This is because the database login information in phpMyAdmin is still the original, so it cannot be logged in.
Solution: Open the installation directory of phpMyAdmin, find the config.inc.php file, and open it with Notepad or another text editor.
Find $cfg['Servers'][$i]['password'] = ''; Change to the new password you just set, save and exit.
Open phpMyAdmin again, you can connect normally, and the password change is complete.
|