MySQL Import / Export via Command line

Being that I've had to search for this information every time I need to run an export (all too often lately).  Here are the commands to import and export entire MySQL databases via SSH command line.

The -p will require you to enter in the mysql password for whichever user you are using to do the import / export.

mysqldump -u USERNAME -p DATABASENAME > MYDATABASE.sql

mysql -u USERNAME -p DATABASENAME < MYDATABASE.sql

 

Another nice touch, presuming that you want to download the file, is to compress the  MYDATABASE.sql file to minimize bandwidth required when downloading it.  WinSCP provides a nice right-click compression function.

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.