Exporting Data from MySQL

  • Last updated on: 2016-01-20
  • Authored by: Rackspace Support

Use the following MySQL command to export your database.

mysqldump -u root -p database_name > database_name.sql

database_name is the name of your existing database. database_name.sql will be the name of the exported database file.

If your database resides on a remote host (as it would if you’re using Cloud Databases) you’ll need to specify the hostname with the “-h” option, as in:

mysqldump -h host_name -u username -p database_name > database_name.sql

Note: Insert the username you created for username in this command.

It’s also possible to set the “MYSQL_HOST” environment variable to the remote host’s address so you don’t have to enter it on the command line.

If you want to import this data to another database, see our article on Importing Data.

MYSQL Documentation

Continue the conversation in the Rackspace Community.