Import MySQL Dumpfile, in Command Line

Posted on Friday, 30 of December of 2016
1245by Octávio GonçalveslinuxMySQL

Step #1: Upload File To MySQL Server

You can upload data.sql file using the sftp or scp command, enter:
$ scp data.sql myuser@example.com:/home/myuser

Step #2: Login To Remote Server

Type the following command at the shell prompt:
$ ssh myuser@example.com

Step#3: Create Database

In this example we create a mysql database called foo:
$ mysql -u root -p -h localhost
$ mysql> create database foo;
$ mysql> exit;

Step#4: Import Datafile

Type the following command to import sql data file:
$ mysql -u username -p -h localhost foo < data.sql

 

Share or save this article

slashdot