I'm killing myself around this issue since I upgraded from 4.6 to 4.71. MySQLi libraries ARE installed, but as soon as I change my settings.php to 'mysqli://username:password@localhost/database'; I get the drupal error:

Unable to connect to database server

This either means that the username and password information in your settings.php file is incorrect or we can't contact the MySQL database server through the mysqli libraries. This could also mean your hosting provider's database server is down.

The MySQL error was: .

Currently, the username is ... and the database server is localhost.

* Are you sure you have the correct username and password?
* Are you sure that you have typed the correct hostname?
* Are you sure that the database server is running?
* Are you sure that the mysqli libraries are compiled in your PHP installation? Try using the mysql library instead by editing your settings.php configuration file in Drupal.

For more help, see the Installation and upgrading handbook. If you are unsure what these terms mean you should probably contact your hosting provider.

(Running WinXP, PHP 5.1.4, MySQL 5.0.22)

Comments

filiptc’s picture

Could anyone please give me a hand...? I really think I'm missing something out here. Could someone just go over the basics of activating the mysqli extension, so that I have a starting point as to wheather I am indeed missing something out or there's a bug somewhere.

Thanks in advance,
Phil

PS: I get this error in the error.log from apache (2.22 btw):
"[Thu Jun 01 22:59:54 2006] [error] [client 83.45.178.163] PHP Warning: mysqli_error() [function.mysqli-error]: invalid object or resource mysqli\n in C:\\Documents and Settings\\Phil\\My Web\\includes\\database.mysqli.inc on line 49"

filiptc’s picture

Updated to drupal 4.7.3, apache 2.2.3, php 5.1.5, mysql 5.0.24 (community-nt; Charset utf8; Collation utf8_general_ci; Permissions: Create Temporary Tables -> Permitted, Lock Tables -> Permitted) and still having the same problem.

Still need someone to help me out.

Thx,
Phil

NiklasBr’s picture

Did an update to 4.7.4 two days ago and drupal somehow lost connection to MySQL version 5.0.26 and PHP version 5.1.6.

What to do?

graper’s picture

sorry I made comment in wrong post.

Granville
Kirkham Systems

filiptc’s picture

Solved the issue installing latest XAMPP (WAMP packet) and doing a fresh drupal 5 install. MySQLi works flawlessly now though there is no visible performance improvement.

Hugs,
Phil

filiptc’s picture

Had to head back to separate installs because of a problem with the XAMPP apache daemon.

As before MySQL works fine but as soon as I change the line to MySQLi I get the "unable to connect to database" error.

I can't beleive nobody has any clue about what the hell I am missing out or doing wrong...

Phil

filiptc’s picture

Since the temporal use of XAMPP resolved the issue it has to be a misconfiguration of either apache, php or mysql. What on earth am I missing out.

Just summing it up, if I change the $db_url = 'mysql://user:pass@database/table'; (which works) in my settings.php to
$db_url = 'mysqli://user:pass@database/table'; I get the "unable to connect to database" error. The mysqli extension is enabled in 'php.ini'.

What is happening?
Phil

Gribnif’s picture

I had this same problem. First, I diagnosed it by changing the error reporting in includes/database.mysqli.inc. Currently, it looks like:

<p>The MySQL error was: '. theme('placeholder', mysqli_error($connection)) .'.</p>

I changed this to:

<p>The MySQL error was: '. theme('placeholder', mysqli_connect_error()) .'.</p>

In my case, the error message said that it could not open the socket. The reason was that the value for mysqli.default_socket in /etc/php.ini was incorrect. I changed it to match mysql.default_socket, and now my connection works.

filiptc’s picture

Thanks but I don't think that's the issue, since both fields are empty (default socket used). I changed the error reporting thing and got:

The MySQL error was: Can't connect to MySQL server on 'localhost' (10061).

Other ideas?

greg.harvey’s picture

Excellent tip, Gribnif! Changing the error output gave me something meaningful. I was seeing this useless message, but now I get "Access denied for user: ... " so I know what's wrong! I hope this will change in the core. =)

--
http://www.drupaler.co.uk/

greg.harvey’s picture

BTW, in my case this was just that I'd forgotten to allow my database user access through 'localhost' - but because of the reporting mechanism currently used, instead of telling me that, Drupal gave me a meaningless error message! =(

--
http://www.drupaler.co.uk/

filiptc’s picture

Error resolved when I updated the whole system and made a fresh install. Never new what the error was due to...

greg.harvey’s picture

It took you *two years* ??? ;-)

--
http://www.drupaler.co.uk/

filiptc’s picture

It didn't take me anything. I just gave up on the problem, forgot about it and when I checked it wasn't there anymore. I just figured out migration must have taken care of it. Not like it was too critical anyways.

greg.harvey’s picture

Sorry. I was only teasing you. I figured it would be something like that. It amused me that you posted two years after the original support request though. Funny! ;-)

--
http://www.drupaler.co.uk/

filiptc’s picture

No need to apologize. When stumbling across this thread I had my doubts too of updating being worth it, but it just felt right over leaving my support request open.

dimes’s picture

I have the same error but i have a hosting and How can I resolve

Warning: mysqli_error() [function.mysqli-error]: invalid object or resource mysqli in /home/ethrcatc/public_html/includes/database.mysqli.inc on line 89

Warning: Cannot modify header information - headers already sent by (output started at /home/ethrcatc/public_html/includes/database.mysqli.inc:89) in /home/ethrcatc/public_html/includes/common.inc on line 141
Unable to connect to database server

If you still have to install Drupal, proceed to the installation page.

If you have already finished installing Drupal, this either means that the username and password information in your settings.php file is incorrect or that we can't connect to the MySQL database server. This could mean your hosting provider's database server is down.

The MySQL error was: .

Currently, the username is ethrcatc_admin and the database server is localhost.

* Are you sure you have the correct username and password?
* Are you sure that you have typed the correct hostname?
* Are you sure that the database server is running?
* Are you sure that the mysqli libraries are compiled in your PHP installation? Try using the mysql library instead by editing your settings.php configuration file in Drupal.

For more help, see the Installation and upgrading handbook. If you are unsure what these terms mean you should probably contact your hosting provider.