How to export a mysql database via the linux command line

How to export a mysql database via the linux command line

Popular content

Donate to Us


Donate by clicking Ads :)

Recent comments

Who's online

There are currently 0 users and 16 guests online.

How to export a mysql database via the linux command line


Prerequities:

You need to have MySQL client installed.

Dumping a database is usefull when moving data and backup data.

These examples 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 > database_name.sql 

Replace username, password and database_name with your MySQL username, password and database name. File database_name.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 > database_name.sql 

Gunzip 
mysqldump -u username -h localhost -p database_name | gzip -9 > backup_db.sql.gz

mysqldump -u username -h localhost -p database_name | bzip2 -c > backup_db.sql.bz2

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

Share/Save
10
Average: 10 (1 vote)
Your rating: None
Tags
Comments

Post new comment

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

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.