Migrating a WordPress database is a crucial step when moving your website to a new server or hosting provider. While phpMyAdmin is a popular tool for importing databases, it often has limitations — especially with large SQL files.
That’s where SSH (Secure Shell) comes in handy. Using SSH allows you to import or migrate your WordPress database faster, securely, and without size restrictions.
This article will walk you through how to perform a WordPress database migration by SSH login on hosting platforms like Hostinger, cPanel, or any other Linux-based hosting.
Why Use SSH for WordPress Database Migration?
When dealing with large WordPress websites, the phpMyAdmin upload limit (usually 256 MB or less) can become a hurdle. Importing over SSH removes this restriction and provides:
- Faster data transfer than browser-based tools
- Better control and automation via command line
- More reliable imports for large or complex databases
- Enhanced security through encrypted connections
Step 1 – Prepare for the Migration
Before starting your WordPress database migration by SSH login, follow these preparation steps carefully:
- Upload your SQL backup file
- Use FTP or your hosting’s File Manager to upload the database backup (e.g.,
database.sqlordatabase.sql.gz) to yourpublic_htmlfolder.
- Use FTP or your hosting’s File Manager to upload the database backup (e.g.,
- Create or reset your target database
- Log into your hosting control panel and create a new MySQL database.
- If you plan to overwrite an existing one, clear it first.
- Confirm your database credentials
- Note down the database name, username, and password.
- If you’ve forgotten the password, reset it before proceeding.
Step 2 – Connect to Your Server via SSH
Once your backup is uploaded, it’s time to connect to your hosting account using SSH.
- Open your terminal (Mac/Linux) or PuTTY (Windows).
- Use this command to log in to your hosting account:
ssh [email protected] - Navigate to your website’s root directory:
cd public_html - Verify that your SQL file is visible. If not, recheck your upload path via File Manager.
Step 3 – Import the WordPress Database via SSH
Now comes the main part — importing your database file.
If your file is compressed (.sql.gz):
Decompress it first using:
gzip -d database_name.sql.gz
(Replace database_name with your actual file name.)
To import the SQL file:
Use the following command format:
mysql -u database_username -p database_name < file.sql
For example:
mysql -u u123456789_admin -p u123456789_database < database.sql
Then, enter your database password when prompted.
The import process will start immediately. Once it finishes successfully, you’ll see:
-bash-4.2$
⏱️ Note: The process duration depends on your database size. Large WordPress databases may take several minutes to complete.
Step 4 – Update the WordPress Configuration File
After importing the database, update your WordPress configuration so your site connects to the new database.
1. Open the wp-config.php file located in your website’s root folder.
2. Update these values with your new credentials:
define('DB_NAME', 'new_database_name');
define('DB_USER', 'new_database_username');
define('DB_PASSWORD', 'new_database_password');
define('DB_HOST', 'localhost');
3. Save the file and close it.
Your WordPress site is now successfully connected to the new database!
Final Verification
- Visit your website URL and ensure it loads correctly.
- Log in to your WordPress admin dashboard to confirm everything is working.
- If you encounter errors, double-check credentials in the
wp-config.phpfile or reverify the SQL import path.
Conclusion
Performing a WordPress database migration by SSH login is one of the most efficient ways to move or restore your website database — especially for large sites. It’s faster, safer, and bypasses upload limitations that come with phpMyAdmin.
Once you get comfortable with SSH commands, you’ll find this method invaluable for managing and migrating databases with minimal downtime.
FAQs About WordPress Database Migration by SSH Login
Can I use SSH for all hosting providers?
Most modern web hosts like Hostinger, Bluehost, and SiteGround support SSH access. Make sure SSH is enabled in your hosting account.
What if my SQL file is too large?
SSH doesn’t have strict file upload limits like phpMyAdmin. However, you should ensure your hosting plan allows sufficient storage.
How do I know if the migration was successful?
Once imported, open your website and WordPress dashboard. If both load without errors, the migration was successful.
Can I use this method for multisite WordPress setups?
Yes, SSH migration works for both single and multisite WordPress installations.