XAMPP修改mysql的默认密码的三种方法

 

* How I can set a "root" password in MySQL? (method 1)

In the xamppmysqlin directory enter into the console:
mysqladmin -u root password secret
Ok, "secret" should be your secret password. Then update the password for PHPMyAdmin. Open the "config.inc.php" in xamppphpmyadmin an edit following lines:

INSTEAD OF ...

$cfg['Servers'][$i]['user']          = 'root';
$cfg['Servers'][$i]['password']      = '';
NOW ...
$cfg['Servers'][$i]['user']          = 'root';
$cfg['Servers'][$i]['password']      = 'secret';
 

Set a new 'root' passwort with mysqladmin

* How I can set a "root" password in MySQL? (method 2 )

Well, there is still another possibility to set the root password. Start PHPMyAdmin with http://127.0.0.1/phpmyadmin, open the database "mysql" (never delete this!) and use the table "user". Create here a new user or e.g. simply change the password of "root." MySQL restart! After that, do not forget to change the password in the "xampp/phpmyadmin/config.inc.php" for PHPMyAdmin.

* How I can set a "root" password in MySQL? (method 3 )

This method based on a suggestion by Ruedi from Basel. With that: Thanks and Grüssli to Switzerland!

Tip: Resetting the password can be make also with the /xampp/mysql/resetroot.bat. After that, the password is empty means "". 

Step 1: Run cmd
C: program files apachefriendsxamppmysqlin>mysqld-nt --skip-grant-tables 

Step 2: Run cmd
C:>C: program filesapachefriendsxamppmysqlinmysqladmin -u root flush-privileges password "newpwd" 

Step 3: Stopping MySQL
C:>C: program filesapachefriendsxamppmysqlinmysqladmin -u root -p shutdown
Enter password: ****** (newpwd) 

Step 4: Edit the “config.inc.php” for the access of PHPMyAdmin
C: program filesapachefriendsxamppphpmyadminconfig.inc.php
Here search for "root"
'$cfg['Servers'][$i]['password'] = 'newpwd'; // MySQL password 

Step 5: MySQL restart

 

转载:http://www.apachefriends.org/zh_cn/faq-xampp-windows.html#password0

原文地址:https://www.cnblogs.com/Camier-myNiuer/p/3472509.html