Current Path : /home/usr.opt/mysql57/mysql-test/include/ |
FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64 |
Current File : //home/usr.opt/mysql57/mysql-test/include/backup_tables_priv_and_users.inc |
# ==== Purpose ==== # # To backup/restore contents of the tables: mysql.tables_priv and mysql.user # # ==== Usage ==== # # # Backup mysql.user & mysql.tables_priv tables # --let $backup=1 # --source include/backup_tables_priv_users.inc # # # Restore mysql.user & mysql.tables_priv from backup # --let $restore=1 # --source include/backup_tables_priv_users.inc if ($backup) { # Save a copy of the user/tables_priv tables, to restore later CREATE TEMPORARY TABLE tmp_backup_tables_priv AS SELECT * FROM mysql.tables_priv; CREATE TEMPORARY TABLE tmp_backup_user AS SELECT * FROM mysql.user; # Reset the backup flag --let $backup= 0; } if ($restore) { # Restore the saved contents of mysql.tables_priv and mysql.user TRUNCATE TABLE mysql.tables_priv; INSERT INTO mysql.tables_priv (SELECT * FROM tmp_backup_tables_priv); DROP TEMPORARY TABLE tmp_backup_tables_priv; TRUNCATE TABLE mysql.user; INSERT INTO mysql.user (SELECT * FROM tmp_backup_user); DROP TEMPORARY TABLE tmp_backup_user; # Reset the restore flag --let $restore= 0; }