How to Import and Export MySQL Database Command line in Linux

Share this Article :

import and export MySQL database command line in LinuxIn this article, I will show you how to import and export MySQL database command line in Linux. In this case, export is to backup while import is to restore. The syntax are very simple and easy to understand and suitable for all levels of users including beginners. This MySQL command line is useful for those who want to migrate their WordPress blog from shared hosting to virtual private server (VPS) hosting or from current VPS hosting to new VPS hosting. This MySQL Database Import and Export command has been tested on CentOS 6 and CentOS 7 and Oracle Linux either on MySQL or MariaDB database.

How to Export MySQL Database Command line in Linux

1. Syntax to Export:

mysqldump -u USERNAME -p DATABASE_NAME > filename.sql

How to Export MySQL Database Command line in Linux

2. Syntax to Import:

mysql -u USERNAME -p DATABASE_NAME < filename.sql

Example :

Export WordPress_DB :

[[email protected] ~]# mysqldump -u WordPress_User -p WordPress_DB > WordPress_DB.sql

Import WordPress_DB :

[[email protected] ~]# mysql -u WordPress_User -p WordPress_DB < WordPress_DB.sql

I hope this article gives you some ideas and essential guidance on how to import and export MySQL database command line in Linux.

 

Leave a Reply