📘Restore MySQL Database

Environment: Linux-based server with MySQL
Access Required: SSH root access


Step-by-Step Instructions

1. Upload the SQL File

Login as the root user via SSH and upload the .sql file you want to restore to the /root folder.

Example:

/root/example_db.sql

2. Run Restore Command

Execute the following command to import the SQL file into the desired database:

mysql -u root -p -h localhost example_db < /root/example_db.sql
  • Replace example_db with the name of your target database.
  • You’ll be prompted to enter the MySQL root password.

3. Enter MySQL Root Password

You may be prompted for the MySQL root password. If you don’t know it, retrieve it from WHM:

WHM Path:
Home » SQL Services » MySQL Root Password


4. Done

The contents of example_db.sql will now be restored to the example_db database.


Tip: Make sure the database (example_db) already exists before restoring, or create it with:

mysql -u root -p -e "CREATE DATABASE example_db;"
Scroll to Top