Skip to content

Instantly share code, notes, and snippets.

@rushipkar90
Last active December 30, 2022 18:25
Show Gist options
  • Save rushipkar90/1ba40c5913d048b92331 to your computer and use it in GitHub Desktop.
Save rushipkar90/1ba40c5913d048b92331 to your computer and use it in GitHub Desktop.
To dump all the innodb databases present on the server - dumpmysql-innodb.sh
#/bin/bash
for i in `cat /usr/local/src/innodb_databases-08012016.txt`; do
mysqldump -ER $i > /home/mysqldump-08012016/$i.sql;
done
//Before executing above script, file innodb_databases-08012016.txt which contains list of all the innodb databases must be present
on the location. To get the list of all innodb databases, use below commands
To find out Innodb databases
================
mysql -N mysql -e "SELECT table_schema, table_name FROM INFORMATION_SCHEMA.TABLES WHERE engine = 'innodb';" | awk '{print $1}' | sort | uniq > /usr/local/src/innodb_databases-08012016.txt
find /var/lib/mysql -name "*.ibd"|awk -F / '{print $5}'|sort -n|uniq > /usr/local/src/innodb_databases-08012016.txt
MySQL variables used are
-e, --execute=name Execute command and quit. (Disables --force and history file.)
-N, --skip-column-names Don't write column names in results.
================
//
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment