Menu

FIX: "Access denied...when using LOCK TABLES"

boodle
2006-11-03
2013-05-29
  • boodle

    boodle - 2006-11-03

    Error:
    "mysqldump: Got error: 1044: Access denied for user 'XXX'@'localhost' to database 'XXX' when using LOCK TABLES"

    find line in script:

    # Database dump function
    dbdump () {
    mysqldump --user=$USERNAME --password=$PASSWORD --host=$DBHOST $OPT $1 > $2
    return 0
    }

    change to: 

    # Database dump function
    dbdump () {
    mysqldump --user=$USERNAME --password=$PASSWORD --host=$DBHOST $OPT --skip-opt $1 > $2
    return 0
    }

    Here is the explaination in brief from (http://dev.mysql.com/doc/refman/5.0/en/mysqldump.html) (worth the read).
    So you can use my fix or roll your own.
    p.s. you can selectively turn options on or off.

    boodle
    ******************************************************************************************
    To get a list of the options your version of mysqldump supports, execute mysqldump --help.

    Some mysqldump options are shorthand for groups of other options. --opt and --compact fall into this category. For example, use of --opt is the same as specifying --add-drop-table --add-locks --create-options --disable-keys --extended-insert --lock-tables --quick --set-charset. Note that all of the options that --opt stands for also are on by default because --opt is on by default.

    To reverse the effect of a group option, uses its --skip-xxx form (--skip-opt or --skip-compact). It is also possible to select only part of the effect of a group option by following it with options that enable or disable specific features. Here are some examples:

    *

    To select the effect of --opt except for some features, use the --skip option for each feature. For example, to disable extended inserts and memory buffering, use --opt --skip-extended-insert --skip-quick. (As of MySQL 5.0, --skip-extended-insert --skip-quick is sufficient because --opt is on by default.)
    *

    To reverse --opt for all features except index disabling and table locking, use --skip-opt --disable-keys --lock-tables.

    When you selectively enable or disable the effect of a group option, order is important because options are processed first to last. For example, --disable-keys --lock-tables --skip-opt would not have the intended effect; it is the same as --skip-opt by itself.

    mysqldump can retrieve and dump table contents row by row, or it can retrieve the entire content from a table and buffer it in memory before dumping it. Buffering in memory can be a problem if you are dumping large tables. To dump tables row by row, use the --quick option (or --opt, which enables --quick). --opt (and hence --quick) is enabled by default as of MySQL 5.0 to enable memory buffering, use --skip-quick.

    If you are using a recent version of mysqldump to generate a dump to be reloaded into a very old MySQL server, you should not use the --opt or --extended-insert option. Use --skip-opt instead.

     
    • boodle

      boodle - 2006-11-03

      Can also do it like this: (using --skip-lock-tables)

      find line in script: 

      # Database dump function 
      dbdump () { 
      mysqldump --user=$USERNAME --password=$PASSWORD --host=$DBHOST $OPT $1 > $2 
      return 0 

      change to: 

      # Database dump function 
      dbdump () { 
      mysqldump --user=$USERNAME --password=$PASSWORD --host=$DBHOST $OPT --skip-lock-tables $1 > $2

      return 0 

       
    • SPWAW_Depot

      SPWAW_Depot - 2008-01-23

      What about just giving the user LOCK TABLES privs?

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.