Import a MySQL database using the Linux command line

From SuperbHosting Support Wiki

Jump to: navigation, search

How to Import a mysql database from a linux command line

Here, we import a database. Use this to restore data from a backup or to import from another MySQL server. Start by uploading the FILE.sql file to the server where you will be running this command, or you can upload it to any linux shell account and just use the -h flag for hostname and put the FQDN after the -h

mysql -u username -ppassword database_name < FILE.sql

Replace the username and password with your own information.

This powerful, easy to use command has many uses.

an example of this using it from a remote host would be like this

mysql -u username -h hostnameof.server.at.superb.net -ppassword database_name < FILE.SQL
Personal tools