Import and Export Database in MySQL Using MySQLdump Command

MySQL is very popular database to store data for web application. Several high-traffic web sites use MySQL for its data storage and logging of user data, including Flickr, Facebook, Wikipedia, Google, Nokia and YouTube. MySQL dump is very important command to get backup of your tables and database. PHP use inbuilt function exec() to execute mysql dump command.

How to export data from mysql

Select Code
1
mysqldump –-user [user name] –-password=[password] [database name] > [dump file]

How to import data from mysql

Select Code
1
mysqldump –-user [user name] –-password=[password] [database name] < [dump file]

How to export multiple database data from mysql

Select Code
1
mysqldump –u[user name] –p[password] [database name 1] [database name 2] .. > [dump file]

How to export table data from mysql

Select Code
1
mysqldump –u[user name] –p[password] [database name] [table name] > [dump file]

How to export multiple table data from mysql

Select Code
1
mysqldump –u[user name] –p[password] [database name] [table name] .. > [dump file]

above all command contain structure with data, sometimes we need only export data.

How to export only table data from mysql

Select Code
1
mysqldump –u[user name] –p[password] --no-create-db --no-create-info [database name] [table name] .. > [dump file]