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;
> 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.