Hi, everyone:

what does the "unable to to select database" error mean? Where did I go wrong during installation? The database shows up on the phpmyadmin page.

Thank you.

pz

Comments

jvandyk’s picture

Typically it means to check your sites/default/settings.php file.

Or if you are using sites/www.example.org/settings.php file to make sure you have the name of the folder right.

pz29’s picture

I got it figured out--thank you.

pz

Darrell’s picture

When you figure something out, PLEASE share it.
I'm glad you figured it out but I am still getting the stupid no help message.

Darrell’s picture

I have searched and RTFM.
If I change anything in the name of the database to make it wrong in settings.php on the

$db_url = 'mysql://me:337nA@mysite.com/dru1';

line I still get the "Unable to Select Database" error.
If I make anything in either user or password wrong I get a
Warning: mysql_connect(): Access denied for user:
error.
If I make anything in the Localhost name wrong I get

Warning: mysql_connect(): Unknown MySQL Server Host.
This tells me that I have settings.php right and the database is there and it has database.mysql loaded.
Where do I go from here?
This is a clean new install of ver 4.6.3.

phillynet’s picture

I Get:

"Fatal error: Call to undefined function: mysql_real_escape_string() in /var/www/html/cm2/includes/database.mysql.inc on line 239"

Then if I make password wrong I get:

"Warning: Access denied for user: 'user@localhost' (Using password: YES) in /var/www/html/cm2/includes/database.mysql.inc on line 31

Warning: MySQL Connection Failed: Access denied for user: 'user@localhost' (Using password: YES) in /var/www/html/cm2/includes/database.mysql.inc on line 31
Access denied for user: 'user@localhost' (Using password: YES)"

I also have similar problems on lower version debian package, I have tried this on RH9, Ubuntu badger and breezy, this is driving me crazy, I know the user has proper privs to database tec..

I also know I am not the only one with this problem, followed install.txt every time.

Heine’s picture

What php version are you using?

PS It's not the same

--
Tips for posting to the forums.
When your problem is solved, please post a follow-up to the thread you started.

phillynet’s picture

Heine,

Appreciate your quick reply, I am using 4.2.2-17. Sorry if posted in wrong thread.

Thanks!

Heine’s picture

I'm afraid I have to tell you that you need to upgrade PHP if you want to use Drupal. Drupal requires PHP 4.3.3 or higher.

Doesn't matter that you posted in this thread, but try to be careful not to preempt a full diagnosis :-).
--
Tips for posting to the forums.
When your problem is solved, please post a follow-up to the thread you started.

phillynet’s picture

Thanks, and yes, I am guilty of preempting a full diagnoses, my apologies. and thankyou for being part of open source

TuringChina’s picture

I didn't got any message about the error.
and the mysql_connect_db() return false.
and I am sure that I have all the privlege and the database exist.

does PHP4 support the function statement:mysql_connect_db() ?

Darrell’s picture

Drupal requires PHP 4.3.3 or higher.

agentpt’s picture

I had the same problem as you. When I added a user to the database in Cpanel I added it under the heading "Users" where you can add a user and password and got the error "Unable to select database" when I pointed my browser to the site

What I omitted to do was to click on "Add user to database" above this. Once I've done that the problem was solved.

Hope this helps

theoa’s picture

It would be interesting to know if this message was generated by drupal or mysql. If it's drupal - then a suggestion of "you may need to add the user to database" could be helpful...

khawarameer’s picture

Hi i am having same problem which u were having... plz tell me how did you add the address of database in settings.php...

i have the database named drupal in "var/lib/mysql/drupal" folder what command should i enter in settings.php file ...

tell me plz...

foot01’s picture

I was getting the error - "Unable to connect to database" and cannot log into with user blah blah - well, I FORGOT TO CREATE the mysql database content.

I simply went into phpmyadmin and imported the database / database.mysql

And now it works.

I'm a bonehead sometimes.

-G

ari-rushan’s picture

It happened to me but I didn't forgot to load the database.mysql. it means the table was created.
But the problem remain.
Does anybody knows any other solution to the problem ?

TheFikr

MLongmire’s picture

I just installed on my gentoo box and had the same "Unabled to select database failure". After reading a few posts here and checking my files, I found that I had entered the db_url and base_url correctly. I connected to mysql and all is good(>mysql -u drupal -p).

When I 'ls' my drupal/sites directory, I see that I have two directories now. The default directory where I have been modifying the settings.php file like crazy and another direcotry named after the base_url I had entered the first time(mlongmire.net) in defaults. It finally dawned on me to check the settings in that directory and what I found was that the database name was set incorrectly. Mine was named 'mldrupal' instead of 'drupal'. I corrected the db_url value in settings.php in sites/mlongmire.net and everything started working great.

This is not a serious drupal installation, just messing around with it.

HTH
Mark Longmire
http://mlongmire.net/drupal
gentoo linux 2.6.14
mySql 4.1.14
php 5.1.2
drupal 4.6.5

smxguitarist@hotmail.com’s picture

I had the same trouble... always double check your settings.php and make sure your database name and username are entered CORRECTLY (as in they're not the same). it's a dumb mistake but it's happened to me.

opal’s picture

Ha, well, I got the exact same error. do you know it was a simple typo in the db name? Spent hours searching for the solution...ditto on the dumb mistake. :-P

bosiorob’s picture

Hi, i had the same problem after settings the second site managed by same installation of drupal.
I solved giving the access to two different database (one for each site) to two different users.
maybe this can help.....
cheers

roberto bosio
http://bosiorob.homelinux.org/

jtrant’s picture

i had this same problem with a backup install on the same machine as the 'real' drupal install. database user names were the same, all that differed was the database name in the settings.php file.

i changed the 'host name' from the name of the machine to 'localhost' and it solved the problem. so the line in settings.php reads:

$db_url = 'mysql://drupal-user:password@localhost/drupalbackup';

/jt