My blog has moved!

You should be automatically redirected. If not, visit
http://benohead.com
and update your bookmarks.

Wednesday, April 11, 2012

mysql: Access denied to information_schema when using LOCK TABLES

We're backing up all our mysql databases with a script similar to this script. But we do backup also the information_schema database.

When doing so we got the following error:

mysqldump: Got error: 1044: Access denied for user 'admin'@'%' to database 'information_schema' when using LOCK TABLES

(on a system with Plesk, the admin user is just like the root user).

The problem is basically that this user doesn't have the right to LOCK TABLES.

So one solution is to grant this user the required rights:

mysql> GRANT SELECT,LOCK TABLES ON information_schema.* TO 'admin'@'localhost';

Another solution is to use the --skip-lock-tables option which will perform the dump without using LOCK TABLES (but tables may be dumped in completely different states):

#mysqldump -u admin -h localhost --skip-lock-tables -pxxxxxx information_schema

Or you can also use the --single-transaction so that a START TRANSACTION SQL statement is executed at the beginning and a consistent state is achieved without LOCK TABLES:

#mysqldump -u admin -h localhost --single-transaction -pxxxxxx information_schema

No comments:

Post a Comment