FAQ: MySQL Connection Problems on Installation

Moderator: mcsmom

Post Reply
User avatar
kenmcd
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 126
Joined: Thu Aug 18, 2005 2:09 am
Location: California
Contact:

FAQ: MySQL Connection Problems on Installation

Post by kenmcd » 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.
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.
Last edited by kenmcd on Sun Jan 01, 2006 7:29 am, edited 1 time in total.

“How do you know I’m mad?” said Alice.
“You must be,” said the Cat, “or you wouldn’t have come here.”

lowhead

Re: FAQ: MySQL Connection Problems on Installation

Post by lowhead » Sun Dec 18, 2005 2:28 pm

I have the same issue. I use:
Apache 2
PHP 5.1.0
MySQL 5.0.15
I changed in PHP.ini so that extention reads: extension=php_mysqli.dll
I renamed the database as described elsewhere from Joomla in the include directory.
However, if I load the index.php (pre-installation check) I get the MySQL support Unavailable.
I created a script in PHP to test if mySQL connection works and it does. So what are the next steps?

Marcel

User avatar
mags
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Sun Feb 19, 2006 5:55 pm
Location: Middle Georgia, US
Contact:

Re: FAQ: MySQL Connection Problems on Installation

Post by mags » Sun Feb 19, 2006 7:44 pm

Ok... I started at around 6am this morning.  Got MYSQL 5.0 and PHP 5.1 up and running by 10:00AM... but have been getting the MySQL Connection problems on installation error.  Now I have to go into town for about an hour...b4 I can get back to this.  I tried the below post... any other suggestions?  Could send the php.info file if that'll help?
thanks... I'm in US and a long..long term dev. friend of mine in Singapore talked me into Joomla this morning.  I'm going to try and present it tomorrow.
yes I'm babbling... but I'm tired!  :-[
------------------------------------------------------
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.

Quote
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.
=========================
Technology is 90% Logic and 9% Luck.
The other 11% is something called math.
=========================

User avatar
mags
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Sun Feb 19, 2006 5:55 pm
Location: Middle Georgia, US
Contact:

Re: FAQ: MySQL Connection Problems on Installation

Post by mags » Tue Feb 21, 2006 1:01 am

OK... There are a lot of reasons why the connection may not work.  Mine was a simple error.  After hours of looking over the installation, I finally found it. I'm not saying that YOU'RE installation problems will be solved by this answer... but it is worth sharing.
I don't use default installations, especially on web servers.  I change allot of things... but this one involved a path.  To be honest, I don't remember exactly which one (I was wrapping up a rather long day of staring at an error message) but I believe it was in the config.inc.php file.  Basically, if you are getting this error... be sure...wait ... be VERY sure that you check all the paths in the config files.  That's all my issue took to fix.  I used a c:\ instead of X:\ in the path of one of the directories.
That's my story and I'm sticking to it.
=========================
Technology is 90% Logic and 9% Luck.
The other 11% is something called math.
=========================

arqa

Re: FAQ: MySQL Connection Problems on Installation

Post by arqa » Fri Nov 17, 2006 2:13 pm

hi
i renamed database.php to database.mysql.php and database.mysqli.php to database.php
but is show mysql support unavailable


i am in fedora 5 and php 5 and mysql 4.1


so what is solution

i will appreciated

SG4

Re: FAQ: MySQL Connection Problems on Installation

Post by SG4 » Tue Nov 27, 2007 5:44 pm

Hello, I have been reading articles relating to mysql not starting in conjunction with Joomla and they do seem rather complicated. Now, I wonder if anybody can place the answer to my question in relatively simple terms please. AS you my have guessed I am quite new to this so, as brief as I can:
I have

Apache v2
Mysql v 5
php v5
I loaded all these via the xampp program. When Installing Joomla I get a message saying "unable to connect to the database:could not connect to mysql"

If anybody could explain how to resolve this in simple terms (if possible) I would be very grateful indeed!

Many thanks

designmanfx

Re: FAQ: MySQL Connection Problems on Installation

Post by designmanfx » Thu Feb 21, 2008 2:34 am

some great info here! good job guys!! keep it up


Post Reply