How to Import a WordPress SQL Backup via Terminal (Example)

Let’s assume you are importing a SQL backup file for a website called exampleblog.com.ng.

🧾 Step-by-step Commands:

bash
# Step 1: Go to the directory where the SQL backup is located:
cd /var/www/exampleblog.com.ng/public_html

📂 This moves you into the folder where your .sql.gz file is stored.


bash
# Step 2: Decompress the SQL backup file:
gunzip exampleblog_dbbackup.sql.gz

🗜 This command unzips exampleblog_dbbackup.sql.gz into a usable SQL file: exampleblog_dbbackup.sql.


bash
# Step 3: Import the SQL file into the MySQL database:
mysql -u root -p exampleblog_db < exampleblog_dbbackup.sql

🔁 This imports the uncompressed SQL file into the MySQL database named exampleblog_db.

🔐 Note: You’ll be prompted to enter the MySQL root password before the import begins.


✅ Summary of Variables Used:

Variable Example Used Explanation
Domain exampleblog.com.ng The website’s domain name
SQL Backup File exampleblog_dbbackup.sql.gz Compressed database file
MySQL Database Name exampleblog_db The database into which you’re importing
MySQL Username root Administrative MySQL user

Leave a Reply

Your email address will not be published. Required fields are marked *