In this tutorial we’ll learn how to import large mysql databases via ssh terminal command line interface. Large mysql database is the issue when you import it via phpMyAdmin and its limit for uploading is lower then your initial mysql db size. In this case we need to import that database via command line – ssh or terminal.
It is always recommended to import database via mysql command line because it is easy and give less overhead like corrupted tables etc.
I always do mysql databases export and import via command line only.
Follow the below commands to import mysql database:
mysql database_name < database.sql
example usage of this command suppose your database name is “blawp_db” and you’ve database backup named “wordpress_cms.sql” uploaded in “/home” dir.
then the command need to be used like :
cd /home mysql blawp_db < wordpress_cms.sql
if you’ve database archive you need to extract it before importing via upper command :
if your database is archived in zip eg : database.sql.zip
if your database is archived in gzip eg : database.sql.gz
if gunzip command doesn’t work install the package :-
For RHEL/Centos :
yum -y install gzip gunzip
for Debian/Ubuntu :
apt-get install gzip gunzip