MySQL I : Table Locking

1. Login to the MySQL Monitor client.
2. Use the “accounting” database:
USE accounting;
3. Lock the tables you will be using:
LOCK TABLES expenses READ, expense_categories READ;
4. Flush the tables (put table in its most current state):
FLUSH TABLES expenses, expense_categories;
5. Backup the tables to your “c:\temp” directory:
BACKUP TABLE expenses, expense_categories TO ‘c:/temp’;

– Note: This is yet another way to do backups.
6. Unlock the tables so that others may use them:
UNLOCK TABLES;

Don’t forget to do this step or no one else will be able access data!
7. Check your “c:\temp” file for MyISAM “MYD” files.