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.

In XAMPP, the default password for accessing phpMyAdmin is usually "blank", which means you can leave the password field empty when prompted for it. However, you can set a password for phpMyAdmin by editing the configuration file located at /path/to/xampp/phpMyAdmin/config.inc.php.

The password for connecting to the MySQL server using mysql_connect() is the password for the MySQL user that you are trying to connect as. By default, the MySQL user "root" has no password on XAMPP, so you can leave the password field blank when calling mysql_connect(). However, you can set a password for the root user by running the following command in the MySQL console:

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('yourpassword');

Watch a course Learn object oriented PHP

You will then need to use this password when calling mysql_connect().

It is generally a good idea to set a password for the root user for security reasons.