mysql backup table code example
Example 1: mysql backup database
mysqldump database_name > database_name.sql
Example 2: mysql backup table
mysqldump db_name table_name > table_backup.sql
Example 3: mysql backup query
mysqldump database > backup-file.sql;
mysql database < backup-file.sql;
Example 4: mysql dump with table query
mysqldump db_name table_name
Example 5: mysqldump 1 table only
mysqldump db_name table_name > table_name.sql
Example 6: mysql backup certain tables
mysqldump -u... -p... mydb t1 t2 t3 > mydb_tables.sql
DBTODUMP=mydb
SQL="SET group_concat_max_len = 10240;"
SQL="${SQL} SELECT GROUP_CONCAT(table_name separator ' ')"
SQL="${SQL} FROM information_schema.tables WHERE table_schema='${DBTODUMP}'"
SQL="${SQL} AND table_name NOT IN ('t1','t2','t3')"
TBLIST=`mysql -u... -p... -AN -e"${SQL}"`
mysqldump -u... -p... ${DBTODUMP} ${TBLIST} > mydb_tables.sql