Using Putty To Import A Database

Posted on by Donald in Database, How-To 7 Comments

Do you have a database too big to import using phpMyAdmin? Well if you have root access, you can use Putty to import a database for you. If you’ve never used Putty before it could be daunting task the first time, I know it was for me. But after learning the basics and one of the most import features, its cake now!

Using putty ~

One trick that basically got me started was being able to copy and paste! It’s actually fairly easy, but not obvious. Simply copy the text your want to use from any location, and right click into putty to paste. Note: When pasting a password your password won’t show up after right-clicking. It’s there, but you can’t see it.

So to paste into Putty, simply right click your copied text in the window and that’s it.

Once you’re logged into your server using Putty. Ask your server admin if you’re having trouble doing this, its cake to import your database.

First you’ll need to make sure the database you want imported is uploaded to your website directory. Using any of your favorite FTP programs, upload the SQL file now. This would be your database backup file.

puttyOnce your SQL file is uploaded, your need to change your Putty directory to the location where you file is located.

To change your directory in Putty, use the cd command followed by the directory you want to change to. For me the command would be:

cd /var/www/vhosts/aspkin.com/httpdocs

This takes me to aspkin.com httpdocs directory where my SQL file would be located.

Your command would be similar to this depending on your server. Ask your server admin for path information to your httpdocs directory if you need it. If your SQL file is located here, you’re half way done!

Using the dir command, you can see what files you have in your directory. Try it now.

dir

If you see your SQL file, that’s good. If not, change your directory to find your file.

Once you’ve found your file use this command to import your SQL file to your database.

mysql -u dbusername -p databasename < backupname.sql

Make sure to change dbusername, databasename, and backupname.sql to your data.

Once you use this command, you’ll be prompted for your database password. Enter that and your database will be imported!

Congrats!

P.S. Using phpMyAdmin you can check to see that all tables have been imported and you’re good to go.