Export and import MySQL databases via SSH

If you want to import your MySQL database through SSH on your VPS or dedicated server, use the following command:

mysql -u username -p database < file.sql

username – the username for the MySQL database, database – database name, file.sql - the file you want to include the MySQL dump.

After running the command you should enter the password for MySQL database, in case to complete the importing.

If you want to export MySQL database through SSH, use the following command:

mysqldump -u username -p database > file.sql

 

  • 52 Users Found This Useful
Was this answer helpful?

Related Articles

How to remove a user from a MySQL database in cPanel

How to remove a user from a MySQL database in cPanel? You need to log in to the cPanel while...

How to Change a MySQL Database Users Password in cPanel

How to Change a MySQL Database Users Password in cPanel? First you should log in to the cPanel...

How to see the MySQL variables

Log into your MySQL database and type: show variables; You will see the following: mysql>...

Optimize MySQL database for more speed

If the MySQL database access times seems high and you feel a slow down you need to optimize your...

Can I connect to MySQL from my computer

Yes, you can. Just need to add your IP address in the hosts allowed to connect to MySQL. Adding...