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

 

  • 56 Users Found This Useful
Was this answer helpful?

Related Articles

Can’t connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'

If you receive this error message when connecting to MySQL trough command line on your VPS...

How to create a MySQL database user in cPanel

How to create a MySQL database user in cPanel? Log in to the cPanel while using username and...

Which host and port to use to connect to MySQL

MySQL host (hostname): localhostMySQL port: 3306  

How to Manage a MySQL Database with phpMyAdmin in cPanel

How to Manage a MySQL Database with phpMyAdmin in cPanel? In order to manage a MySQL database...

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...