Lesson #12

April 11, 2013

Import SQL database into MySQL (command line)

I really hope you have phpmyadmin, because you're going to need it for this, otherwise I'll update this later with details on how to export your database in MySQL.

This exercise is to show you how to export your database and import it to an empty database on another server.  

Let's get started,

Exporting Database

Log into phpmyadmin and select the database you want to export by clicking its name from the left pane.

There will be a tab at the top of the list of tables of your database that says 'export' click that.

You will be brought to a screen with a bunch of details, skip that and go to the bottom and check "Save as file", I usually just leave the Compression as None.

Click the 'Go' button.

The filename.sql file will now download.

Importing database

Fire up your shell / ftp and place the .sql file on your server.

This is where the fun begins, you need to enter these commands in the same directory as you stored the file on your server.

log into mysql:

#  mysql -u username -p
If the database you want to use isn't already in place, create it.
# exit;

From the Linux command line enter the following to import your database, you will be prompted to enter your password.

# mysql -u username -p database < filename.sql

Double Checking

Now you're done, to double check that it was imported correctly, log in, select your database and show the tables, all your tables should be there.

# mysql -u username -p  
# USE database;

author: clearskyy





holla at us

ComputersCSSFoodGamesGearHardwareHealthHTMLHumorjQueryLaptopsMobileMoviesMusicMySQLNewsOnline ServiceOperating SystemPeripheralsPetsPHPRandomSoftwareSportsTV ShowsUnsortedVlog

Thanks for checking us out ♥

Hand coded with the blood, sweat, tears, and demonic infant sacrifices made by no other than Nate Seymour.


Icons made by Icomoon, SimpleIcon, Freepik, Madebyoliver, Google from www.flaticon.com is licensed by CC BY 3.0