Access denied for user ‘root’@’localhost’

Posted: 0p in MySQL

mysqldump: Got error: 1044: Access denied for user ‘root’@’localhost’ to database ‘information_schema’ when using LOCK TABLES

You can pass the –single-transaction option to mysqldump command:
$ mysqldump –single-transaction -u user -p DBNAME > backup.sql

Another option is to grant LOCK TABLES to your user:
$ mysql -u root -p

And type:
mysql> GRANT SELECT,LOCK TABLES ON DBNAME.* TO ‘username’@’localhost’;

Sample Shell Script

# Purpose: Backup mysql
NOW=$(date +”%d-%m-%Y”)
# set mysql login info
MUSER=”root” # Username
MHOST=”″ # Server Name

# guess binary names
MYSQL=”$(which mysql)”
MYSQLDUMP=”$(which mysqldump)”
GZIP=”$(which gzip)”

[ ! -d “${DEST}” ] && mkdir -p “${DEST}”
# get all db names
DBS=”$($MYSQL -u $MUSER -h $MHOST -p$MPASS -Bse ‘show databases’)”
for db in $DBS
FILE=${DEST}/mysql-${db}.${NOW}-$(date +”%T”).gz
# get around error
$MYSQLDUMP –single-transaction -u $MUSER -h $MHOST -p$MPASS $db | $GZIP -9 > $FILE


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s