Forums

unable to backup database

HI,

I followed help instructions to backup SQL database with following:

mysqldump -u yourusername -h yourusername.mysql.pythonanywhere-services.com --set-gtid-purged=OFF --no-tablespaces 'yourusername$dbname'  > db-backup.sql

keep getting bellow error:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL 
server version for the right syntax to use near 'mysqldump .........' at line 1

Not sure what I'm doing wrong.

Thanks

Run that in a Bash console, not a MySQL console.

Hi Glenn,

Thanks for highlighting that.

what would be the format if i need only a specific table?

Im also getting bellow error while running it:

Unknown table 'COLUMN_STATISTICS' in information_schema (1109)

See https://help.pythonanywhere.com/pages/MySQLBackupRestore/

After some searching I managed to sort it out.

Leaving it for anyone facing same problem.

For bellow:

Unknown table 'COLUMN_STATISTICS' in information_schema (1109)

add to your my.cnf:

[mysqldump]
column-statistics=0

Regarding backing up only a certain table:

 mysqldump -u yourusername -h yourusername.mysql.pythonanywhere-services.com --set-gtid-purged=OFF --no-tablespaces 'yourusername$dbname' yourtablename > db-backup.sql

Yes, that will work well! The help page that @glenn linked to above suggests a similar, but not identical way to do the same thing -- add --column-statistics=0 to the mysqldump command-line options.