Linux, import large database to MySQL with help the console

June 2, 2016 12 Alex

Quick import of large database

Open the console (terminal) and connect to an SSH server.

If MySQL database is already created

Go to MySQL:

mysql -uYourLogin -pYourPassword

Replace YourLogin and YourPassword on your login and password.

Now select the database:

use DBName

Where DBName is name of the database for import of data.

And do import from file:

source dumpFile.sql

Where dumpFile.sql is the name of the data dump, or the path to it.

If a MySQL database does not exist yet

If database does not exist yet, it is possible to import with help the following command:

mysql -uYourLogin -pYourPassword db_name < /path/to/dumpFile.sql

Database export via MySQLDump

mysqldump -uYourLogin -pYourPassword DBName > fileDBName.sql