Web Hosting - Dedicated Servers
Dedicated Server Hosting
Web Hosting eCommerce Hosting Reseller Hosting Dedicated Server
Home

Restoring a MySQL database over SSH

Written by WebHosting Moderator   
Wednesday, 19 March 2008

Sometimes you will have a database backup that is too big to restore over a web interface. The best way to restore large SQL backups is through SSH, and all it takes is one command. This tutorial will show you how.

First of all, connect to your server via SSH and login as root/elevate yourself to root status. Here is the command we are going to use:

mysql -u user -p password -h host database_name < backupfile.sql

You need to change the bold sections. A brief explanation of each:

  • user: The user who has access to the database you are importing data into
  • password: Password of the user
  • host: The database host. This is usually localhost
  • database_name: Name of the database you want to import data into
  • backupfile.sql - Name/location of the backup file you want to import.

Here is a proper example:

mysql -u john -p johnspass -h localhost johns_db < /home/john/backups/backup.sql

In this example, we are importing the file backup.sql into the database johns_db, using the user john, and the database host is localhost.

This could take a while depending on the size of the database. Once you are returned to the command line, the import has been completed. It is a good idea to check in phpMyAdmin or a similar tool to make sure that the database imported correctly.

If you want to learn how to backup a database over SSH, take a look at this tutorial:

tutorials.ausweb.com.au/web/Tutorials/Linux/Backing-up-databases-over-SSH/




If you found this tutorial helpful, you can bookmark it with your favourite tracker.

Reddit!Del.icio.us!Google!Live!Facebook!Slashdot!Netscape!Technorati!Blinklist!Yahoo!Ma.gnolia!Squidoo!
 
< Prev   Next >
 
 
RedHat Linux
cPanel Hosting
plesk windows
Fantastico SiteBuilder
 

AUSWEB Web Hosting PTY LTD © 2008 Network Info Data CenterPrivacy PolicySLA Terms and Conditions