Export a MySQL database using the Linux command line

From SuperbHosting Support Wiki

Jump to: navigation, search

How to export a mysql database via the linux command line

This howto shows you how to export a mysql datbase with mysqldump which is a tool to import and export MySQL databases. It can be used to back up a database or to move database information from one server to another.

This example shows you how to export a database. It is a good idea to export your data often as a backup.

First connect to the mysql server that has the database and use this command line.

mysqldump -u username -ppassword database_name > FILE.sql

Replace username, password and database_name with your MySQL username, password and database name. File FILE.sql now holds a backup of your database, download it to your computer.

Or

you can do this from your Linux shell

mysqldump -u username -h hostname.of.server.com -ppassword database_name > FILE.sql

This will remotely connect to the server and download it if you're remote.

Personal tools