As the question says, I have been trying to export each table of a database in individual .sql files. I know mysqldump -u username -p DBName TableName > Export.sql
exports one specific table, but is there any way I can loop it and export all tables in individual files using SSH command?
Find the tables in the database and iterate over it.
mysql -u USERNAME -p -N -D DATABASENAME -e 'show tables';
This will list the tables of a particular database. Do something like this to export all the tables of the database. ( Note: you need to remove the formatting charaters )
for tab in `mysql -u USERNAME -p -N -D DATABASENAME -e 'show tables';` do
mysqldump -u USERNAME -p DATABASENAME $tab > ${tab}.sql
done
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.