Jump to content

When to lock tables?


angelcool

Recommended Posts

Sorry but I forgot to be more detailed in my last post.

 

When locking tables, do users are still able to read from DB ?

 

My logic dictates to allow users only to read records and NOT to allow any insert, updates, etc.(or any query that will modify db/table content)  while backup is going on; this way the backup will be consistent.

 

I got the following in bash:

[root@localhost ~]# mysqldump --help | grep lock
  --add-locks         Add locks around insert statements.
                      --skip-disable-keys --skip-add-locks
  -x, --first-slave   Deprecated, renamed to --lock-all-tables.
                      using --lock-all-tables or --master-data: in this case
                      moment all tables are locked. So if you want your dump
                      should use --lock-all-tables or --master-data with
  -x, --lock-all-tables
                      by taking a global read lock for the duration of the
                      --lock-tables off.
  -l, --lock-tables   Lock all tables for read.
                      --lock-all-tables on, unless --single-transaction is
                      specified too (in which case a global read lock is only
                      of the dump.Option automatically turns --lock-tables off.
  --opt               Same as --add-drop-table, --add-locks, --create-options,
                      --quick, --extended-insert, --lock-tables, --set-charset,
                      automatically turns off --lock-tables.
  --skip-opt          Disable --opt. Disables --add-drop-table, --add-locks,
                      --lock-tables, --set-charset, and --disable-keys.
add-locks                         TRUE
lock-all-tables                   FALSE
lock-tables                       TRUE

 

Not sure what parameter to use.

I have googled "MySQL backup tutorial" but none of the tutorials found explain this.

 

I will really appreciate that someone experienced help me clarify this.

 

Angel

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.