How do I change the mysql password if I forget the mysql password under Linux

  • 2020-05-15 02:39:30
  • OfStack

The initial password is empty, use the empty password to log in mysql and execute the following statement


mysql>use mysql;
mysql> UPDATE user SET password=PASSWORD("root") WHERE user='root';
mysql> FLUSH PRIVILEGES;
mysql> quit;
 Modify the /opt/lampp/phpmyadmin/config.inc.php

Find the following code:


$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['AllowNoPassword'] = true;

Is amended as:


$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'root';
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['AllowNoPassword'] = true;

The above is about how to change the mysql password if you have forgotten the mysql password under Linux. I hope it will help you.


Related articles: