MySQL "root" user default state is no password , so in PHP you can use mysql_connect ("localhost", "root", "") to connect to the MySQL server;
If you want to set a password for the "root" user in MySQL (for example: the native MySQL password is 123456), use the "mysqladmin" command in the console. For example:
d:\PHP\xampp\mysql\bin\mysqladmin.exe-u root Password 123456
In addition, if there is a previous secret, the Modify command is:
D:\PHP\xampp\mysql\bin\mysqladmin.exe-u root-p Password 123456
Enter the password, enter the "old password" can be.
Note that after you change the root password, do not forget to change the information in the PHPMyAdmin. Search for "config.inc.php" under ... xamppphpmyadmin and edit the following lines:
$cfg [' Servers '] [$i] [' user '] = ' root ';//MySQL SuperUser
$cfg [' Servers '] [$i] [' auth_type '] = ' http '; HTTP MySQL authentification
From now on, you need to enter the "root" password correctly to start PHPMyAdmin.
The new password will take effect after restarting the MySQL service!
Reference:
<?php$cfg[' blowfish_secret ' = ' a8b7_snsgou.com_c6d ';/* Servers configuration */$i = 0;/* server:localhost [1] */$i + + $cfg [' Servers '] [$i] [' verbose '] = ' localhost ', $cfg [' Servers '] [$i] [' host '] = ' localhost '; $cfg [' Servers '] [$i] [' Port ' ] = "; $cfg [' Servers '] [$i] [' socket '] = '; $cfg [' Servers '] [$i] [' connect_type '] = ' TCP '; $cfg [' Servers '] [$i] [' extension '] = ' mysqli '; $cfg [' Servers '] [$i] [' auth_type '] = ' cookie '; $cfg [' Servers '] [$i] [' allownopassword '] = false;
How do I change the root password of MySQL in xampp?