« SAS Log Options | Main | Getting started with ODK - Install Aggregate on Ubuntu 12 »

June 01, 2013

Copy and import a mySQL database

This is the original source.

Createa backup of the database:
$ mysqldump --opt -u [user] -p [db] -h [host] > [filename].sql
- If dropped -h default to localhost.

Create backup with compression:
$ mysqldump --opt -u [user] -p [db] -h [host] | gzip > [filename].sql.gz

Dump and import:
$ mysqldump --opt -u [user] -p [db] -h [host] | mysql -u [user] -p -h [host] [db]
- The first part dumps database 1 and the second part imports the dump into database 2.

Connect to mySQL via command line:

$ mysql -u [dbuser] -h [dbhost] -p


Import a database:

$ mysql -u [dbuser] -p -h [dbhost] [dbname] < [db_toimport.sql]

SFTP into a machine through a non-standard port

$ sftp -oPort=[port] [username]@[host]

Posted by kkwaiser at June 1, 2013 04:37 PM


Login to leave a comment. Create a new account.