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

Loading

Leave a Reply

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