Avatar of Jason Yu
Jason Yu
Flag for United States of America asked on

PDOException: SQLSTATE[42000] [1044] Access denied for user 'lacare_d7'@'localhost' to database.

I got the following error when i cloned my database to a new one with a different name. I tried to reconnect my application tier to the new renamed database, it gave me the error as below.

"PDOException: SQLSTATE[42000] [1044] Access denied for user 'lacare_d7'@'localhost' to database 'lacare_d7_staging' in lock_may_be_available() (line 167 of /var/www/staging/html/includes/lock.inc)."

Since I have root account for this mysql server, I log in and ran successfully the following command:

mysql>  GRANT ALL PRIVILEGES ON lac2014_staging TO 'lac2014'@'localhost';
Query OK, 0 rows affected (0.00 sec)

It doesn't make any difference. Then I checked the file mentioned on the error message:
/var/www/staging/html/includes/lock.inc

got the 167th line as below:

155 /**
    156  * Check if lock acquired by a different process may be available.
    157  *
    158  * If an existing lock has expired, it is removed.
    159  *
    160  * @param $name
    161  *   The name of the lock.
    162  *
    163  * @return
    164  *   TRUE if there is no lock or it was removed, FALSE otherwise.
    165  */
    166 function lock_may_be_available($name) {
    167   $lock = db_query('SELECT expire, value FROM {semaphore} WHERE name = :name', array(':name' => $name))->fetchAssoc();
    168   if (!$lock) {
    169     return TRUE;
    170   }
    171   $expire = (float) $lock['expire'];
    172   $now = microtime(TRUE);
    173   if ($now > $expire) {
    174     // We check two conditions to prevent a race condition where another
    175     // request acquired the lock and set a new expire time. We add a small
    176     // number to $expire to avoid errors with float to string conversion.
    177     return (bool) db_delete('semaphore')
    178       ->condition('name', $name)
    179       ->condition('value', $lock['value'])
    180       ->condition('expire', 0.0001 + $expire, '<=')
    181       ->execute();
    182   }
    183   return FALSE;

Open in new window




Please help me with this hard issue.
MySQL Server

Avatar of undefined
Last Comment
Jason Yu

8/22/2022 - Mon
Jason Yu

ASKER
Here is the copy screen of the error message.
database-connection-error.png
ASKER CERTIFIED SOLUTION
jimyX

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Jason Yu

ASKER
Great, it is working now.

Why my "grant all" command didn't take effect on the tables belong to the "lac2014_staging" database.


mysql>  GRANT ALL PRIVILEGES ON lac2014_staging TO 'lac2014'@'localhost';
Query OK, 0 rows affected (0.00 sec)
SOLUTION
jimyX

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Jason Yu

ASKER
Thank you very much, i appreciate your help.

If I want to read more materials and be a MYSQL dba, where is a good begining?

thanks.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Jason Yu

ASKER
Very good answer, spot the error.
jimyX

> If I want to read more materials and be a MYSQL dba, where is a good begining?

Nothing is better than a good book. There are plenty of free books online.
Also you can read MySQL Reference Manual, it has a lot of information that helps.
And if you read something, in a book or online, and it does not look clear, Google is your friend. You will get tons of explanations and examples.

But reading a book is much better for covering many aspects in an organized way.
Jason Yu

ASKER
thank you for your instruction, I will begin from this document.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.