On some systems (for example, standalone laptops or in test/dev settings) MySQL is installed so it doesn't have database usernames and passwords (essentially, it's in single-user mode). In the Drupal config.php file, the Mysql string would then be something like:

   $db_url = "mysql://localhost/database";

This, however, will generate error messages out of database.mysql.inc, complaining the keys 'user' and 'pass' are not found.

The solution is to patch database.mysql.inc inside the db_connect() function and add the following lines before the mysql_connect() call:

   if (!(array_key_exists("user", $url)))
    $url[["user"]] = "";
    
  if (!(array_key_exists("pass", $url)))
    $url[["pass"]] = "";

I had to manually change this on my copy of 4.3.2 and now with rc and cvs versions. Thought I'd mention it.

I'm new to the Drupal system and am not sure what the process is for patching the core. So I figured I'd post this message and have someone more knowledgeable do it so I wouldn't break things.

Thanks.

Comments

raminf’s picture

The previous fix does not solve the whole problem. It let me load the home page without errors, but I can not create new content. I get:

user error: Access denied for user: '@localhost' to database 'testdb'
query: LOCK TABLES sequences WRITE in c:\inetpub\wwwroot\dpc\includes\database.mysql.inc on line 102.

I'll look around to see if there's any other way around this (short of having to completely remove and reinstall mysql).

Any tips would be welcome.

gordon’s picture

Why do you not add a mysql user thru the MySQL Control Center.

Why do you want to make Drupal less secure when it is very easy to create a new user under mysql.

killes@www.drop.org’s picture

Requiring security is no bug.