HowTo: Import/Export mysql database from shell

To export a database run

mysqldump datbasename > databasename.sql

This will export the database to databasename.sql

To import a database from an sql dump file run

mysql databasename < dumpsqlfilename.sql

This will import the sql file into the database. Once imported you should check to make sure it was correctly imported to do this run

mysql databasename
show tables;

If the you do not see any tables listed then the sql file likely has a USE statement at the top. Edit the sql file with a text editor and comment out the line “USE databasename”. Once commented out attempt to import the data and check the tablesl.

  • Digg
  • del.icio.us
  • Facebook
  • Reddit
  • Slashdot
  • Twitter
No Responses to “HowTo: Import/Export mysql database from shell”

Post a Comment