Import into MySQL database

If you have a MySql database that you want to import (pipe) into another server, as long as you have the filename.sql file you can copy it using WinSCP from the old server to the new server and run the following command;

# mysql databasename < filename.sql

Just replace the “databasename” with the name of the MySql database you want to import to and the filname.sql will be the name of your expoerted sql file.

It is even possible to import directly via IP from one server to another, if you have the correct permissions and open ports etc…… The below code gives an example of this.

# mysql -h ipaddress -p -u root databasename < filename.sql

The “ipaddress” refers to the remote IP address of the server you are importing to. The”databasename” refers to the database name on the remote server and the “filename.sql” refers to the local sql file on the local server.

No warranty is given for any of the code on this page.