How To Import Database Via SSH

Looking for a simple, stable and significant VPS as your web hosting? Check out DigitalOcean, only $5 per month, and you can get $10 in credit just for signing up now.

phpMyAdmin is easy for you to import a MySQL database, but which will not work if your database is too large.

As what you can see from the following captured screen, the max file size that phpMyAdmin can import is only 2,048K:

How To Import Database Via SSH

Which means that if your database is larger than 2,048K, you can’t import it through the phpMyAdmin dashboard, instead, you can import it via SSH.

The following will show you how to import a database from a shared web hosting service to a VPS or a dedicated server via SSH using the Terminal application of a Mac computer:

1. Create a same database

Create a same database with phpmyadmin

You need to create a database with the same database name, username (with same PRIVILEGES) and password as those of the database you want to import, which you can done via the phpMyAdmin or Terminal (for Mac) or Putty (for Windows) app according to WordPress.

2. Export your database

Export your database with phpmyadmin

Login to your phpMyAdmin of your shared hosting, and export your database as a gzip file (such as jingpin.sql.gz ).

3. Upload the gzip file

Upload your gzip file

Open your Terminal (for Mac) or Putty (for Windows) app, and upload the gzip file to your remote server with the following one command line:

scp /xxx/jingpin.sql.gz [email protected]:/var/www

Remember to replace "/xxx/jingpin.sql.gz" with your gzip file's path, to replace "" with your server’s public IP address, and to replace "/var/www" with the folder you want to upload the gzip file to. After that, enter the root password, then you can upload your gzip file.

By the way, if you don’t know the path of your gz file, you can just drag and drop it behind the "scp" command.

4. Uncompress the gzip file

Uncompress sql.gz

Login to your remote server, and get into the folder (such as /var/www) where your gzip file is hold, then enter the following command line:

gzip -d jingpin.sql.gz

Press the Enter key, you can uncompress the gz file to “jingpin.sql” file.

5. Import your database

Import your database

After that, enter the following command line:

mysql -p -u root jingpin < jingpin.sql

Enter the MySQL root user password, then you can import your database to your new remote server.

By the way, you can also replace "root" with the username you set for your new database in the first step.

Spread the love
This entry was posted in Other Free Nuts and tagged , , . Bookmark the permalink.