Unix Linux Shell MySQL To Backup Create Table
The following shell script shows how * Use At Own Risk
cat backup_create_tables.sh
# to run this script
# sh backup_create_tables.sh username password
# pass args $1=username, $2=password or hardcode hostname, dbname, table_name, etc...
mysql -h hostname dbname -u $1 -p$2 -e "SELECT * FROM table_name;" > backup_table_name.txt
mysql -h hostname dbname -u $1 -p$2 -e "DROP TABLE IF EXISTS table_name_backup;"
mysql -h hostname dbname -u $1 -p$2 -e "CREATE TABLE table_name_backup SELECT * FROM table_name;"
To run The following shell script enter
sh backup_create_tables.sh username password
* If permissions are granted this will create backup_table_name.txt(local) and hostname.dbname.table_name_backup table
Both the backup_table_name.txt file and hostname.dbname.table_name_backup containing contents of table_name *
Go Back to:
http://Howes-IT-Going.com
This Webpage and Contents Created by Steven C. Howes © Howes-IT-Going 2009-2012 All Rights Reserved.