FAQ: MySQL Connection Problems on Installation
Posted: Mon Nov 14, 2005 11:11 pm
Q. When installing Joomla, why do I keep getting these errors?
- cannot connect to MySQL
- MySQL not running or not found
- "I get to step ## and it just stops"
A. PHP, MySQL, and Joomla all must be using the same method to connect to MySQL.
If not using the same connection method, Joomla cannot see the database and it is as if the database does not exist.
MySQL may be running just fine, but PHP may not be able to connect.
PHP may be able to connect to the MySQL database, but Joomla may not be using the same connection method.
When either PHP or Joomla are not configured to connect to your particular version of MySQL,
it is as if the database does not exist. And that is what the errors say.
Also, make sure MySQL is actually running first.
PHP
mysqli is a PHP connector (a library) which enables PHP to connect to MySQL databases.
The "i" in mysqli stands for improved. (faster, better, etc.)
mysql is the older version of this PHP connector.
PHP 4.x by default installs with the older mysql connector.
PHP 5.x by default installs with the newer mysqli connector.
PHP 4.x or 5.x may be configured to use either or both of the connectors if needed.
MySQL
The older PHP mysql connector will connect to MySQL 4.0.x and earlier.
The newer PHP mysqli connector will connect to MySQL 4.1.x/5.0.x and later.
Joomla
Joomla includes two PHP files to connect to MySQL.
One version is for using the mysql connector.
One version is for using the mysqli connector.
Switching these files is causing Joomla to change from using the mysql connector to using the mysqli connector.
Problems arise when you do not have PHP, MySQL, and Joomla all using the same connector:
Installed PHP 5 and cannot connect to MySQL 4.0.x or 3.23 - this is because by default PHP 5 installs with the mysqli connector which only connects to MySQL 4.1x/5.0.x and later.
Upgrade the MySQL, or configure PHP to use the older connector.
Installed PHP 5 with MySQL 4.1.x/5.0.x and Joomla cannot connect - that is because by default Joomla uses the older mysql connector. This PHP/MySQL combination should work fine together because they are both using the mysqli connector. Joomla will also use the mysqli connector if you rename the files as explained above. Once that is done all three will be speaking the same connector language - and it will work.
Installed PHP 4.x and MySQL 4.1.x/5.0.x - these MySQL versions require the newer mysqli connector by default. See the PHP web site for info on how to set-up the older version of PHP to connect to these MySQL versions. Or upgrade PHP.
Make sure PHP, MySQL, and Joomla are all using the same connector.
Note: These issues are in addition to the MySQL password hashing issues when upgrading from MySQL 3.23/4.0.x to MySQL 4.1.x/5.0.x.
- cannot connect to MySQL
- MySQL not running or not found
- "I get to step ## and it just stops"
A. PHP, MySQL, and Joomla all must be using the same method to connect to MySQL.
If not using the same connection method, Joomla cannot see the database and it is as if the database does not exist.
MySQL may be running just fine, but PHP may not be able to connect.
PHP may be able to connect to the MySQL database, but Joomla may not be using the same connection method.
When either PHP or Joomla are not configured to connect to your particular version of MySQL,
it is as if the database does not exist. And that is what the errors say.
Also, make sure MySQL is actually running first.
PHP
mysqli is a PHP connector (a library) which enables PHP to connect to MySQL databases.
The "i" in mysqli stands for improved. (faster, better, etc.)
mysql is the older version of this PHP connector.
PHP 4.x by default installs with the older mysql connector.
PHP 5.x by default installs with the newer mysqli connector.
PHP 4.x or 5.x may be configured to use either or both of the connectors if needed.
MySQL
The older PHP mysql connector will connect to MySQL 4.0.x and earlier.
The newer PHP mysqli connector will connect to MySQL 4.1.x/5.0.x and later.
Joomla
Joomla includes two PHP files to connect to MySQL.
One version is for using the mysql connector.
One version is for using the mysqli connector.
From : http://help.joomla.org/content/view/818/132/
Joomla! with PHP 5 and MySQL 4.1
MySQL 4.1 requires the mysqli libraries to be used to access the database.
To be able to install and use Joomla with this configuration:
- rename database.php to database.mysql.php, and then
- rename database.mysqli.php to database.php.
Both files are in the /includes/ directory.
Switching these files is causing Joomla to change from using the mysql connector to using the mysqli connector.
Problems arise when you do not have PHP, MySQL, and Joomla all using the same connector:
Installed PHP 5 and cannot connect to MySQL 4.0.x or 3.23 - this is because by default PHP 5 installs with the mysqli connector which only connects to MySQL 4.1x/5.0.x and later.
Upgrade the MySQL, or configure PHP to use the older connector.
Installed PHP 5 with MySQL 4.1.x/5.0.x and Joomla cannot connect - that is because by default Joomla uses the older mysql connector. This PHP/MySQL combination should work fine together because they are both using the mysqli connector. Joomla will also use the mysqli connector if you rename the files as explained above. Once that is done all three will be speaking the same connector language - and it will work.
Installed PHP 4.x and MySQL 4.1.x/5.0.x - these MySQL versions require the newer mysqli connector by default. See the PHP web site for info on how to set-up the older version of PHP to connect to these MySQL versions. Or upgrade PHP.
Make sure PHP, MySQL, and Joomla are all using the same connector.
Note: These issues are in addition to the MySQL password hashing issues when upgrading from MySQL 3.23/4.0.x to MySQL 4.1.x/5.0.x.