php/mySQL on XAMPP: password for phpMyAdmin and mysql_connect different?
The password for accessing phpMyAdmin and the password for connecting to the MySQL server using the mysql_connect() function can be different.
The password for accessing phpMyAdmin and the password for connecting to the MySQL server using mysqli or PDO can be different.
In XAMPP, the default password for accessing phpMyAdmin is usually blank. If phpMyAdmin uses config authentication mode, you can set a password by editing config.inc.php and adding or modifying:
$cfg['Servers'][$i]['password'] = 'yourpassword';If using cookie or http authentication, phpMyAdmin will prompt for credentials instead of reading them from the config file.
The password for connecting to the MySQL server is the password for the MySQL user you are connecting as. Note that mysql_connect() was removed in PHP 7.0; use mysqli or PDO instead. By default, the MySQL root user has no password on XAMPP. To set one, run this command in the MySQL console (MySQL 8.0+):
ALTER USER 'root'@'localhost' IDENTIFIED BY 'yourpassword';You will then need to use this password when connecting via PHP. For example, using mysqli:
$conn = new mysqli('localhost', 'root', 'yourpassword');It is generally a good idea to set a password for the root user for security reasons.