Copy a database in Linux

Posted by: Jennifer Driller in Web Design

Tagged in: databases

I've been working with a linux server and came across a situation where I needed to essentially copy a database from a development environment to a production environment. Trying to use Plesk to do this boils down to several complications with export/import functions in MySQL, but there is a supremely easy way if your hosting service allows Secure Shell access.

Here are the steps:

Download Putty - A free telnet and SSH Client for Windows and Unix platforms.

Enter your host name or IP address

You will be prompted for your login info. Enter your username. Press Enter. Enter your password. Press Enter.

Switch to root access using this command: su -

You will need a password for root. Enter it and press Enter.

Next type in (or copy/paste) the following command:

mysqldump name_of_1st_database>name_of_1st_database.sql

This will dump all the tables and content into an sql file you can use for backup and restoration.

Then type:

mysql name_of_2nd_database<name_of_1st_database.sql

That takes the dump of content you created and populates the new database with it.

Trackback(0)
Comments (0)Add Comment

Write comment

security code
Write the displayed characters


busy