Last active
March 17, 2022 13:20
-
-
Save raymadrona/e3774a769aea2b42107ad888cc00726b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mysqldump --single-transaction --skip-lock-tables simmfins | pv | gzip > simmfins_$(date +'%Y%m%d_%H%M%S').sql.gz | |
mysqldump -u root -p database_name | gzip > dump.gz | |
scp dump.gz user@other-host:/tmp | |
ssh user@other-host "gunzip /tmp/dump.gz | mysql -Ddatabase_name -B; rm /tmp/dump.gz" | |
zcat /path/to/file.sql.gz | mysql -u 'root' -p your_database | |
// Restore Database (gzip) | |
gzip -dc /path/to/file.sql.gz | mysql -u 'root' -p your_database | |
// Drop all triggers | |
//http://stackoverflow.com/questions/12637945/how-can-i-delete-all-the-triggers-in-a-mysql-database-using-one-sql-statement | |
mysql -u [db user] -p[db password] --skip-column-names [db name] -e 'SHOW TRIGGERS;' | cut -f1 | sed -r 's/(.*)/DROP TRIGGER IF EXISTS \1;/' | mysql -u [db user] -p[db password] [db name] | |
// Import a sql | |
mysql -u username -p database_name < file.sql | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment