I am looking to ignore certain tables during mysql dump do to large size.
/usr/bin/mysqldump -u$DBUSER -p$DBPWD $IGNORETABLES --databases $db | gzip > "$OUTPUTDIR/db-currentdate.sql.gz"
I want to ignore tables using --ignore-table=database.table but my database has a hyphen in the name which breaks. Is there a way to escape the database name with the hyphen. Please remember I am doing this via command line and not php (that would be to easy!)
The IGNORETABLES variable will be built from a table and compared against before final backup.
I have it working on tables within database without hyphen. As soon as I put in one with hyphen it gives all tables. **Please note that database naming convention was a result of parallels control panel which used (domain_com_-_database)
You need to put back ticks arround your database name db-name
eg
mysqldump 'db-name' > db-name.sql
Which version of MySQL are you using? This seems to work fine for me with 5.5.40.
I tried it with:
CREATE DATABASE `domain_com_-_database`;
USE `domain_com_-_database`;
CREATE TABLE a (i INT);
CREATE TABLE b (i INT);
And then:
mysqldump --ignore-table=domain_com_-_database.b --databases domain_com_-_database
The output only contains table a, no b.
(Sorry, I know I should have posted this as a comment, but I don't have the reputation to do that.)
I am actually running the command as a shell script. Not via mysql command line. Basically I only get a single line to submit at a time and the "-" breaks (doesn't ignore)
MySQL Version 5.5.30
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.