I recently received this error message:

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. This could mean your hosting provider's database server is down.

The MySQL error was: Access denied for user: 'root@localhost' (Using password: YES).

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

Here is why I posted in Post Installation: This error happened some weeks after I had installed and had a successfull go of it. I had added lots of content, etc.

This error suddenly appeared without warning one day when I went to the site, and where a few days before it was working.

In the beginning, I had used cPanel/Fantastico to install Drupal, and it went well.

Who can say what went wrong? (I had just before this failure, used cPanel/Fantastico to install another software package. Perhaps that caused the problem?)

Beats me, and I am sure everybody else. Just how could an error like this happen? I could use phpMySqlAdmin to access the Drupal database, and it gave no indication of a problem. I actually even exported the database, downloaded the Drupal installation and installed it on my home PC, where I used phpMySqlAdmin to import the database. I then modified the lcoal settings.php file for the local MySql user/password and I have the old online site fully back in operation locally.

I even just used cPanel/Fantastico to install a second copy of Drupal on my website, in another directory, it it too works fine.

But there is the screwy thing: When installed via cPanel/Fantastico, the password string in settings.php is encrypted, and Drupal's documentation, and my local installation bears this out, says to use the plaintext password!

Which is correct? Is there a setting somewhere to encrypt the password?

Of course, why my Website database password suddenly changed on me, wil probably not ever be determined (unless I screwed something by accident as I did use cPanel to install some other software).

Anyway, I can simply switch to the new website's Drupal, I just need to redo all my configurations.

Does Drupal have a backup and restore function?

Thanks all for listening. (And Drupal rocks!)

Comments

mrfrazzlebottom’s picture

I just found the Backing Up Your Drupal Site post (http://drupal.org/node/22281).

Looks like with some careful work I can restore everything.

It must have been one of the subsequent cPanel/Fantastico installs that accidentally mucked something.

One question remains: Why does the Fantastico install store the password encrypted? (i.e I used password banana (not really, just an example) and the settings.php string written was like:
$db_url = 'mysql://website_drpl1:B7SvC9O040cN@localhost/website_drpl1';. (I assume the result of a one-way hash.)

BlackSash’s picture

Just edit the file directly (without using that frontend), and replace the hash with the normal plaintext version of the password. That should get the site back working again.
It might be worth investigating what exactly caused the file to be altered with the hashed password, since it may happen again later on, if you need to install some other piece of software.

-------------------------------
GU d- -p+ c++++ l++ e* m* s+ n+ h+ f? g+ w+++ t- r y?
Madcap - design - development - consultancy
http://www.madcap.nl - Running on Drupal, of course.

mrfrazzlebottom’s picture

Here is another question. (Yes, I frequently talk to my own threads.)

Does Drupal strore all of it's configuration data in it's MySql database? Or, for example, when I Add Block, or modify the 'links' block, body are all the changes stored solely in the MySql database, or are there some HTML or PHP file(s) also modified?

I am investigating (locally I just monitor file accesses) while making changes. Looks like everything is stored in the MySql database.

I'll bet I can just import my previous data into the new installation on my website.

Well, thanks again for listening.

sepeck’s picture

Almost everything is stored in the database. You need also the settings.php file. The files directory. Any custom theme you have. Any modules you wrote/modified.....

Oh heck. Just backup the Drupal directory as part of your backup/restore process.

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide -|- Black Mountain

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide

brisbanett’s picture

The mysql error was: Access denied for user 'xxxx_drpl1'@'localhost' (using password: YES)
my host was attacked by a virus - and now i have the same - i need a dumbed down explanation how to solve this please help.