I refreshed my page and all of a sudden this error shows up.

PDOException: SQLSTATE[28000] [1045] Access denied for user 'username'@hostdomain' (using password: YES) in lock_may_be_available() (line 165 of "site path"/public_html/site/includes/lock.inc)

I thought it to be a server error and contacted the host, but they say everything is fine from their side and might be a problem in code. I check the settings.php, looks ok. I'm able to access the database using PHPMyAdmin.

I'm unable to locate the error.

Can someone help me out with this one.

Comments

marcvangend’s picture

Category: bug » feature
Priority: Critical » Normal

This is does not look like a Drupal bug, but like incorrect configuration. If it was a Drupal bug, you should update your RC3 to 7.0 stable or 7.x-dev before reporting bugs.

Are you 100% certain that the correct username, password and database name are in your settings.php? A single character can make all the difference...

marcvangend’s picture

Category: feature » support

Oops, I meant support request.

yudhistir’s picture

Yes, everything is fine. Actually, I set up the site almost a month ago and yesterday I was checking the user permissions and suddenly there it goes. I get this error for some strange reason.

I don't remember meddling with the settings.php, which I did still check and found everything to be okay.

marcvangend’s picture

There is a strange single quote in your error message, where it says 'username'@hostdomain'. Is it there in the original error message as well? (I can imagine that you edited the username before posting it here.)

yudhistir’s picture

Version: 7.0-rc3 » 7.0

Ok, I now really have a problem.

After the post #3, I deleted the entire CMS and database and installed a fresh drupal 7.

I was working on it and suddenly this error came up again.

In reply to post #4, the error is as below:

'username'@'hostdomain'

Thanks for the help.

marcvangend’s picture

Does the error always occur, or just once in a while?
If it was working and the error occurred just like that (without any action from your side), I think the problem is in the database server.

petespoll’s picture

Priority: Normal » Major

I have the same issue, I am trying to include some php. My question is now how to get back in and remove the code, so I can try something else.

Thanks,
Dan

GNA27’s picture

Please, could someone explain exactly why this is happening and post clear instructions for a fix?

I was following directions that were posted previously for copying an entire site and database for working offline in Drupal.

I have a site that I started building on a temporary domain, and I followed the exact steps. I copied over the entire web folder for the site with its exact structure, and I then exported the site's SQL database and imported it into a new database for the offline version of the site.

But I get nothing but error messages when trying to bring up the site. If I enter localhost/sitename/user, it takes me to a default screen, but there is no way to login, logout, or find out why I cannot reach the actual site and administer it.

There are many questions related to this on Drupal.org and other websites, but I am a relative beginner to Drupal and I am not familiar enough with all the .ini and .php files to start modifying code and using some of the exotic work-arounds suggested.

bfroehle’s picture

Looks like your database configuration in settings.php is incorrect.

petespoll’s picture

Thanks for the response. That is what I thought as well bfroehle, but I think in my case, it is more related to the database that I added (it is a custom application written in PHP). However, I am trying to figure out how to get back into admin, then I will remove the content. I should have been smart enough to include it in an external page first for testing. There is not a specific folder that custom apps need to be placed into is there?

Thanks,
Dan

petespoll’s picture

okay. I loaded a generic page with the include statement, and .php extension, and it calls the application very well. So the issue is most-likely in the content that I added (or Drupal), and nothing to do with the app itself, or the associated database. For content in my settings, I enabled php, and entered only the include statement for front page content. Maybe it needs more content than the single statement? Maybe I need to start php? Maybe some special coding to work in Drupal?

I added to my front page content:

include("/hsphere/local/home/****/****.net/articles#/newstop.php");

Nothing else.

marcvangend’s picture

yudhistir, GNA27, petespoll: you may receive the same error message, but that doesn't necessarily mean that you're looking at the same problem. This thread is getting a bit messy because we're discussing 3 situations at once. Anywaym, now that we're here:

yudhisir: As said if your problem occurs sometimes, but not always, I suspect that the problem is on the server level, not in Drupal.

GNA27: I agree with bfroehle, check your database settings.

petespoll: If your php code returns proper html without errors, it should work in theory. That said, including php like that is not recommended at all. Read about writing your own module and implementing hook_menu.

petespoll’s picture

Thanks. Any idea how to get back into the site admin?

http://fcsfootball.net

marcvangend’s picture

petespoll: are you sure the database connection info in settings.php is correct?

GNA27’s picture

So what should the settings.php look like if that is the issue? Where would the problem be located, and how could it be fixed? Again, I have zero experience with these files, so I have no idea what my database settings being incorrect would mean.

Almost my entire settings.php file is nothing but explanatory notes. It seems to me that there is minimal real content.

marcvangend’s picture

It's about the part starting with $databases =.
Usually, it will look like this:

$databases['default']['default'] = array(
  'driver' => 'mysql',
  'database' => 'databasename',
  'username' => 'username',
  'password' => 'password',
  'host' => 'localhost',
  'prefix' => 'main_',
  'collation' => 'utf8_general_ci',
);

When you move your site to another server, you often need to change the values for 'database', 'username' and 'password'. The correct settings depend on how you (or your webhost) set up your database.

petespoll’s picture

GNA27:

Since you and I did basically the exact same thing, with the copying files and database, and we have the exact same error ...I just thought that I would let you know somehow my password did change in the Drupal settings.php file. Don't ask me how. I know I did not do it. I suspect you may find the same thing ...my password said "drup417". Hope this helps

jn2’s picture

I'm having the same problem as GNA27.

Edited: It was a settings.php problem. Sometimes those things really hide from you.

samba-77’s picture

Hi all,

I had the same problem without changing machine, I resolve it now.
My problem was when I installed D7 I didn't have set password for database.
After installation I change password on my database for root and after that I couldn't connect to my site;
So now I just set the password as describe above and now it is ok.

Saïd.

cweagans’s picture

Priority: Major » Normal

Support requests are never critical or major.

pasqualle’s picture

Status: Active » Closed (fixed)