mysql backup certain tables

Solutions on MaxInterview for mysql backup certain tables by the best coders in the world

showing results for - "mysql backup certain tables"
Hailey
13 Aug 2017
1-- If you are dumping tables t1, t2, and t3 from mydb
2
3mysqldump -u... -p... mydb t1 t2 t3 > mydb_tables.sql
4
5/* If you have a ton of tables in mydb and you want to dump everything 
6--except t1, t2, and t3, do this: */
7
8DBTODUMP=mydb
9SQL="SET group_concat_max_len = 10240;"
10SQL="${SQL} SELECT GROUP_CONCAT(table_name separator ' ')"
11SQL="${SQL} FROM information_schema.tables WHERE table_schema='${DBTODUMP}'"
12SQL="${SQL} AND table_name NOT IN ('t1','t2','t3')"
13TBLIST=`mysql -u... -p... -AN -e"${SQL}"`
14mysqldump -u... -p... ${DBTODUMP} ${TBLIST} > mydb_tables.sql