Import/Export Database Through The Terminal In Linux/Ubuntu



Some times if we are working with the huge database then it is not possible to Import/Export all the database through the phpMyAdmin, phpMyAdmin has time limit and it can not Import/Export the huge database and it breaks the process due to the time limit. In this case we can Import/Export the database by using the Shell Commands. These commands are given below:

Import database through the SSH

For Importing the database through the SSH

Step 1. Open the terminal.
Step 2. Login through the SSH

ssh {user_name}@{host_name}

Step 3. Press Enter then it will ask for the Password after entering the Password you will be logged in.

Step 4.

mysql -u {database_username} -p {database_name} < filename.sql

Enter the Database User Name and the Database Name and the filename and press Enter then it will ask for the Password after putting the Password it will Import the database.

Export database through the SSH

For Exporting the Database use the below command

mysqldump -u {database_username} -p {database_name} > filename.sql

Enter the Database User Name and the Database Name and the filename and press Enter then it will ask for the Password after putting the Password it will Export the database.

Export only one database table through the SSH

For Exporting only the one database table use the below command:

mysqldump -u {database_username} -p {database_name} --tables {database_tablename} > dumpfile.sql

Specify the Database User Name, Database name and database table which you want to Export.

Hope this will help to someone. Enjoy the working on the SSH.