IT/Software/Database Applications/mysql command line/mysqldump: Difference between revisions
Access restrictions were established for this page. If you see this message, you have no access to this page.
Walttheboss (talk | contribs) |
Walttheboss (talk | contribs) |
||
Line 11: | Line 11: | ||
==Dumping To a Remote Host== | ==Dumping To a Remote Host== | ||
=== Dump directly into a remote database === | ===Dump directly into a remote database=== | ||
<code>mysqldump -ulocaluser -plocalpassword | <code>mysqldump -ulocaluser -plocalpassword localdbname | ssh remoteuser@remotehost.com mysql -uremoteuser -premotepassword remotedbname</code> | ||
===Dump to a file on a remote server=== | |||
mysqldump <code>-ulocaluser -plocalpassword localdbname</code> | <code>ssh remoteuser@remotehost.com</code> 'cat > /media/vte/backup_from_vte/databases/moodleVteDump.sql' | |||
When running a mysql dump to a remote host directly over ssh the host database will be locked until the sync has finished. (Can be up to 5-10 minutes for lager databases) | When running a mysql dump to a remote host directly over ssh the host database will be locked until the sync has finished. (Can be up to 5-10 minutes for lager databases) | ||
Revision as of 07:04, 16 February 2020
Options
- You can do this from phpMyAdmin or other GUI based apps.
- See the Applications page for this.
- You can perform the dump to various resources.
- Dump to a text file.
- Dump to a zipped file
- Dump to another database
- Dump to another Database on another server
Dumping To a Remote Host
Dump directly into a remote database
mysqldump -ulocaluser -plocalpassword localdbname | ssh remoteuser@remotehost.com mysql -uremoteuser -premotepassword remotedbname
Dump to a file on a remote server
mysqldump -ulocaluser -plocalpassword localdbname
| ssh remoteuser@remotehost.com
'cat > /media/vte/backup_from_vte/databases/moodleVteDump.sql'
When running a mysql dump to a remote host directly over ssh the host database will be locked until the sync has finished. (Can be up to 5-10 minutes for lager databases)
The above problem can be easily circumvented by adding --quick and --single-transaction to the mysqldump command.
Tells mysql to only retrieve one row at a time.
--quick
Starts the transaction without locking the entire DB.
--single-transaction
Example dump:
mysqldump --verbose --quick --single-transaction -u<localDbUser> -p<localDbPassord> <localDbName> | ssh user@remote.host mysql -u<remoteDbUser> -p'<remoteDbPassword>' <remoteDbName>