Howto Import and Export a MySQL database in SSH

Categories

Howto Import and Export a MySQL database in SSH

You are here:

In this very quick and short article we’ll be explaining how you can import and export a MySQL or MariaDB database using the command-line in SSH.
This is particularly useful when you may be working with large databases and such operations may not be possible to be carried out in phpMyAdmin due to PHP Memory limit restrictions.

In this example we will be working with the following MySQL information, change these according to your own environment. You will need to know the MySQL user credentials to carry out the “import” part of this guide.

MySQL Database: fraction_dev
MySQL User: fraction_user
MySQL Pass: wmWWQXER8iFghii

How to export the database using mysqldump

Using mysqldump we can export the database to an .sql file with the following simple command.
This will export the file to the current directory from which you are working in.

mysqldump fraction_dev > fractiondev.sql

How to import the database using the myqsl command

Using mysql we can import the sql data file into the existing database with the following command.
This will import the file in the current directory from which you are working in.

mysql -u fraction_user -p fraction_dev < fractiondev.sql

Don't forget to replace these parameters with your own.
fraction_user - The MySQL Username that has privileges to access the database with.
fraction_dev - The name of the MySQL database.
fractiondev.sql - The name of the .sql file that you wish to import.

Previous Howto check if ports are open using nmap and netcat
Next LSI Broadcom RAID Monitoring
Table of Contents