Backup a mysql database via SSH

Restore a MySQL Database

To restore an existing .sql backup of a MySQL database, run the following mysql command as root or a user with elevated privileges.

mysql db_name < db_name.sql

You should replace “db_name” with the name of the database you want to restore into, for example “wp_myblog”.

In case you have a combined .sql dump of several databases, specify the single database to be restored with the syntax:

mysql --one-database db_name < multidbs.sql

Create a MySQL Database Dump (Backup)

The mysqldump command creates text file exports of MySQL databases. The resulting .sql files can be used to create an image of the database for duplication or restoration at a later time.

To dump a single database, run the command below to dump the database and write the output text to a .sql file:

mysqldump db_name > db_name.sql

You can also export multiple databases to the same .sql dump. In this command “db_name1” and “db_name2” are the names of individual databases to be exported together.

mysqldump --databases db_name1 db_name2 > databases.sql

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

What MySQL Version I'm Using?

This demo assumes you've already logged in to cPanel 1. On right hand side you have...

How to Backup & Restore a MySQL Database

How to backup Mysql Database.   First, log in to your cPanel using your username and password....

Insert Data Into Your Mysql Database

This demo assumes you've already logged in to cPanel Scroll down to the Databases section...

Remotely Connect to a Databases

Configuring a Remote MySQL Database 1. Log in to your cPanel account. 2. Navigate to the...

How to Grant MySQL Database Privileges to a Database User

To give a user all privileges in MySQL, follow these steps: Log in to your cPanel account....