Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
FREEDOM251

Freedom251 › Blog › Database Backup

How to Import a SQL Database into an Existing WordPress Site Safely

By Freedom251 Team · · 11 min read

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Importing a SQL dump into WordPress means loading it into the MySQL database named in the destination site’s wp-config.php; it is not an operation performed in the WordPress editor. Before replacing anything, back up the current database and all site files, confirm the destination credentials and table prefix, import with phpMyAdmin or WP-CLI, then update any changed domain or path with a serialization-aware search-and-replace. Keep the rollback copies until the site works normally under traffic.

What a WordPress SQL import actually changes

A WordPress SQL dump contains database records such as posts, pages, comments, users, options, taxonomy relationships, plugin settings and widget data. Importing it can replace or add those records in the selected MySQL database. It does not bring back the WordPress application files: themes, plugins, uploaded media, custom code, wp-config.php, web-server rules or other server configuration remain wherever they currently are.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

That distinction explains many failed migrations. A database from one site paired with a different set of theme, plugin and upload files can produce missing images, broken layouts, PHP errors or unavailable plugin settings. Treat the database and the filesystem as two parts of one migration and make sure their versions are compatible before diagnosing SQL.

Prepare the existing site before touching its database

Schedule a maintenance window

Choose a period when visitors and editors are unlikely to be changing content. Put the site in maintenance mode or otherwise prevent writes while you export, import and validate. New orders, comments, form entries or user registrations created during the move can be lost when an older dump is loaded over the destination database.

#1 Best Overall
Sale
Lexar D40E 128GB Dual USB 3.2 Gen 1 Type-C Jump Drive, Champagne Silver | USB-C Flash, Metal Housing, Swivel Design, Thumb Drive
  • USB-C 2-in-1 storage OTG: The Lexar JumpDrive Dual Drive D40E features USB Type-A and Type-C connectors in a slim, portable form factor for easy device compatibility
  • Transfer speeds up to 100MB/s: Based on internal testing, performance may vary depending upon the host device, interface, and usage conditions. 1MB=1,000,000 bytes
  • Plug and Play: Widely compatible with USB Type-C smartphones, tablets, laptops, Macs, and traditional Type-A devices, no software installation required. The 360° swivel design allows for easy switching between connectors without the hassle of losing a cap
  • Durable & Compact: The Lexar D40E USB memory stick features a metal enclosure, withstands temperatures from 0° to 50° C (32°F to 122°F), and is lightweight at 26g with dimensions of 70.4 x 16.9 x 11.7mm
  • Security & Warranty: Securely protects files using an advanced security software solution with 256-bit AES encryption. Backed by a Lexar 3-year limited warranty

Record the current configuration

Write down the values below before making changes. They provide a reference when you need to select the right database or undo a change.

Record Why it matters
Database name, host, user and table prefix Identifies the database WordPress is actually using and the tables that belong to it.
Public URL, protocol and installation path Lets you detect whether links or serialized settings need replacement.
PHP and MySQL versions Helps distinguish an import problem from a runtime compatibility problem.
Active theme and enabled plugins Shows which files and code must match the imported settings.
Multisite status Determines whether network tables and domain mappings require network-aware handling.

Back up both layers

Export the database currently used by the destination site and download or snapshot the complete WordPress directory, including wp-content/uploads, themes, plugins and wp-config.php. The database backup covers content and settings, but not those files. Name the backups with the date and environment, and store a copy outside the server. Do not overwrite or delete the old database until validation is complete.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Check the dump and the target environment

  • Make sure the SQL file is complete and readable, and note whether it is compressed (for example, .sql.gz).
  • Confirm that the destination MySQL account can create, alter, insert into and delete from the target tables as required by the dump.
  • Check available disk space. During an import, the SQL file, temporary files and expanded tables may all occupy space at once.
  • Ensure the PHP version, MySQL or MariaDB version, theme and plugins are supported by the files you will run after the import.

Create or select the destination database

The destination database must exist before either import method can load data. In your hosting control panel or database administration tool, create a database and user, grant the user the necessary privileges, and note the exact host, database name, username and password. Some hosts add an account prefix to names; copy the full names exactly.

Open the destination site’s wp-config.php and verify the corresponding constants:

define( 'DB_NAME', 'database_name' );
define( 'DB_USER', 'database_user' );
define( 'DB_PASSWORD', 'database_password' );
define( 'DB_HOST', 'localhost' );
$table_prefix = 'wp_';

The values shown above are examples, not credentials to copy. The table prefix may be something other than wp_; the imported tables and the configuration must agree. If the dump contains tables with a different prefix, either change the configuration to match or rename the tables deliberately before the site is brought online. Never edit a live configuration without retaining the original file.

Method 1: Import with phpMyAdmin

phpMyAdmin is a browser-based option suited to one-off imports when you have no shell access. Its practical limits are imposed by the hosting account and PHP settings, so large files may fail even when the SQL itself is valid.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Sale
SANDISK 128GB Ultra Flair, USB-A Flash Drive, Up to 150MB/s Read Speeds | USB Flash Drive, Up to 15x Faster than standard 2.0, Password Protection, Durable, Sleek Metal Casing, USB 3.0, Silver/Black
  • High-speed USB 3.0 performance of up to 150MB/s(1) [(1) Write to drive up to 15x faster than standard USB 2.0 drives (4MB/s); varies by drive capacity. Up to 150MB/s read speed. USB 3.0 port required. Based on internal testing; performance may be lower depending on host device, usage conditions, and other factors; 1MB=1,000,000 bytes]
  • Transfer a full-length movie in less than 30 seconds(2) [(2) Based on 1.2GB MPEG-4 video transfer with USB 3.0 host device. Results may vary based on host device, file attributes and other factors]
  • Transfer to drive up to 15 times faster than standard USB 2.0 drives(1)
  • Sleek, durable metal casing
  • Easy-to-use password protection for your private files(3) [(3)Password protection uses 128-bit AES encryption and is supported by Windows 7, Windows 8, Windows 10, and Mac OS X v10.9 plus; Software download required for Mac, visit the SanDisk SecureAccess support page]
  1. Sign in to phpMyAdmin and select the destination database from the left-hand navigation. Check the name against DB_NAME in wp-config.php; selecting a similarly named database is a common and destructive mistake.
  2. Review the existing tables and confirm that your current database backup is stored safely. If you intend to replace the database, do not skip the backup just because the import screen offers a drop-table option.
  3. Open the Import tab, choose the SQL dump, and select the appropriate format and character-set options shown by your host. If the file is compressed, use the compression format that phpMyAdmin supports instead of unpacking it into a temporary location without enough disk space.
  4. Start the import and leave the browser window open until phpMyAdmin reports completion or an error. Do not run the same file again automatically after a timeout; first determine whether the server completed the operation in the background.
  5. Inspect the result for imported tables, row counts and an error message. Keep the previous database available for rollback, even if phpMyAdmin reports success.

When phpMyAdmin stops or rejects the file

  • Upload-size error: the host’s PHP or web-server upload limit is smaller than the dump. Ask the host to raise the limit, split the dump only with a reliable method, or use WP-CLI over SSH.
  • Execution timeout: a browser request ended before MySQL finished. Check whether tables were created and whether the host provides an import-from-server feature; avoid blindly repeating a partial import.
  • Permission denied: grant the database user the privileges required by the statements in the dump, or import into a user with those privileges.
  • Syntax or collation error: record the exact failing statement and the MySQL/MariaDB versions. A dump created by a newer server may use syntax or collations unavailable on the target.

Method 2: Import with WP-CLI

WP-CLI is preferable when the dump is large, the site is managed over SSH, or you want a repeatable migration command. Run it from the WordPress directory, using the same account and configuration that serve the destination site.

  1. Connect through SSH and change to the directory containing wp-config.php.
  2. Confirm that WP-CLI is operating on the intended installation with wp core version and, when appropriate, wp db size. If the path or configuration is ambiguous, specify the path explicitly with --path=/full/path/to/wordpress.
  3. Import the dump with:
wp db import database.sql

wp db import reads DB_HOST, DB_NAME, DB_USER and DB_PASSWORD from wp-config.php. It imports the SQL statements but does not create the database itself. Create the database and grant privileges before running the command.

The command adapts SQL modes that WordPress Core disables, including STRICT_TRANS_TABLES and NO_ZERO_DATE, which can make some legacy dumps import more cleanly. If you must preserve the server’s SQL mode exactly, the --skip-sql-mode-compat option disables that adaptation. WP-CLI also exposes controls for unique-key and foreign-key checks and can pass additional arguments to the underlying mysql client; use those options only when you understand the constraints in the dump.

Use a compressed dump when supported

If the dump is compressed, either decompress it on the server or pipe it according to the WP-CLI version and host documentation. Verify the resulting command against a copy first; a typo in a shell redirection can send input from the wrong file or produce an empty import.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Protect against the wrong path or credentials

SSH sessions often start in a home directory rather than the WordPress directory. Running the command there can invoke another wp-config.php or fail against a different site. Use an absolute path, inspect the database name before importing, and keep a terminal log of the command and its output.

Change the old domain or installation path safely

A database imported from another URL may still contain the old domain in options, post content, attachment metadata, menus, widgets and plugin settings. A simple text replacement is unsafe because PHP serialized values include the length of each string. Changing a URL without updating those lengths can make widgets or settings unreadable.

Rank #3
Sale
2 Pack 64GB USB Flash Drive USB 2.0 Thumb Drives Jump Drive Fold Storage Memory Stick Swivel Design - Black
  • What You Get - 2 pack 64GB genuine USB 2.0 flash drives, 12-month warranty and lifetime friendly customer service
  • Great for All Ages and Purposes – the thumb drives are suitable for storing digital data for school, business or daily usage. Apply to data storage of music, photos, movies and other files
  • Easy to Use - Plug and play USB memory stick, no need to install any software. Support Windows 7 / 8 / 10 / Vista / XP / Unix / 2000 / ME / NT Linux and Mac OS, compatible with USB 2.0 and 1.1 ports
  • Convenient Design - 360°metal swivel cap with matt surface and ring designed zip drive can protect USB connector, avoid to leave your fingerprint and easily attach to your key chain to avoid from losing and for easy carrying
  • Brand Yourself - Brand the flash drive with your company's name and provide company's overview, policies, etc. to the newly joined employees or your customers

Run a dry run first

From the destination WordPress directory, substitute the real old and new URLs in this example:

wp search-replace 'https://old.example' 'https://new.example' --all-tables --dry-run

The dry run reports matches without writing changes. Review the tables and counts, and check whether the old value appears in data that should remain unchanged, such as a documentation link or an external service endpoint. --all-tables broadens the search beyond the standard WordPress prefix; use it only when you have reviewed the scope, particularly on a database that contains unrelated applications.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Write the replacement

After confirming the dry-run output, execute the same command without --dry-run. WP-CLI’s search-replace operation understands PHP serialized data. Use --precise when complex or serialized data needs the more careful processing path and accept that it may run more slowly. Preserve the pre-replacement database backup until every URL and setting has been tested.

Handle multisite deliberately

Multisite stores network and per-site values in different tables. A single-site replacement can miss network data or affect only one site. WP-CLI provides a --network mode for a network-wide operation; determine the correct scope and backup before using it. Do not apply a network-wide replacement to a single-site database merely because the option is available.

Check the canonical URL options

Inspect the home and siteurl values in the options table for the active table prefix. They must reflect the URL and path where the installation is actually served. If the site is installed in a subdirectory, preserve that path consistently rather than replacing only the hostname.

Validate the imported site before reopening it

Validation should use a private browser window or a temporary access restriction first, then normal traffic after the checks pass. Work through the following list rather than relying on the home page alone.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
SIMMAX 32GB Memory Stick USB 2.0 Flash Drives Swivel Thumb Drive Pen Drive (32GB Purple)
  • GOOD VALUE PACKAGE - 1 Pack 32GB Memory Stick USB 2.0 Flash Drives with great cost performance and high quality.
  • BIG CAPACITY - The available capacity: 29.10GB-29.8GB, You can save the data of movies, music, photos, designs, programs, manuals, handouts in a high speed.Good performance in digital data storing, transferring and sharing with families, friends, workmates, clients and machines.
  • EASY TO USE & PLUG AND WORK - Support windows 7 / 8 / 10 / Vista / XP / 2000 / ME / NT Linux and Mac OS, Compatible with USB2.0 and below.
  • TWISTTURN DESIGN & EASY CARRY - The metal clip rotates 360° round the ABS plastic body which with rubber oil skin feeling finish. The capless design can avoid lossing of cap, and providing efficient protection to the USB port.
  • WARRANTY & SUPPORT - SIMMAX logo is laser printed on the USB connector surface, our products are of good quality and we promise that any problem about the product within one year since you buy.
  • Open the front end and several posts, pages, category archives and search results.
  • Sign in at /wp-admin and confirm that the expected administrator account works. If login fails, verify the imported users table, cookies and URL settings before resetting credentials.
  • Load representative images, PDFs and other uploads. Check browser developer tools for media requests still pointing to the old host or path.
  • Open menus, widgets, forms, editor blocks and plugin screens that store serialized settings.
  • Check permalinks by visiting a post and a page, then go to Settings > Permalinks and click Save Changes once to regenerate rewrite rules. This does not alter the selected structure.
  • Clear WordPress, page, object and CDN caches only after confirming that the underlying site is correct. A stale cache can hide a successful replacement or continue serving old URLs.
  • Review PHP and web-server logs for database errors, missing files, fatal plugin errors and redirect loops.
  • Test forms, transactional email hooks, scheduled tasks and any external integrations that depend on the domain, credentials or server paths.

Keep the maintenance window in place until these checks succeed. Once normal traffic resumes, monitor logs and key transactions before removing the rollback copies.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Common failure points and targeted fixes

“Error establishing a database connection”

Verify that DB_NAME, DB_USER, DB_PASSWORD and DB_HOST match the database you imported. Confirm that the user is permitted to connect from the web server and that the server is running. This message does not prove that the SQL import failed; it often indicates a configuration or privilege mismatch.

The site loads but content is missing

Check that the imported tables use the prefix named in $table_prefix. A database can contain perfectly valid rows that WordPress ignores when it is looking for another prefix. Also confirm that the matching uploads directory and active theme files were restored; a database-only import cannot supply them.

Images or links still use the old domain

Inspect the generated HTML and database values, then run a scoped, serialization-aware search-replace with a dry run. Check protocol differences such as http versus https, subdirectory paths and values stored by plugins in tables outside the standard prefix.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

“Unserialize” warnings, broken widgets or lost settings

These symptoms commonly follow a raw SQL or command-line text replacement that changed string lengths inside serialized PHP data. Restore the pre-replacement backup if necessary and repeat the change with WP-CLI search-replace, using --precise for complex data.

Admin redirects endlessly or the front end points elsewhere

Check home and siteurl, HTTPS configuration, reverse-proxy settings and any hard-coded URL constants in wp-config.php. Clear caches only after correcting the canonical values; otherwise cached redirects can obscure the fix.

Best Value
IMEASON Swivel Design 16GB USB Flash Drive with Keychain, USB 2.0 Portable Thumb Drive Memory Stick, FAT32 Format Flashdrive for Data Storage, Photos, Music, Files (Black, 16 GB)
  • 【16GB Flash Drive】USB flash drives with 16GB capacity, meet your needs of daily use on work, school, home and travelling for photos, music, videos, files storage and transfer. IMEASON thumb drives can be used to store different files, easy to data backup.
  • 【Metal Swivel Cap Design】USB thumb drive is metal swivel cover provides extra protection for the usb thumbdrive connector, no usb drive cap to lose; keychain design makes it easier to carry without worrying lose it.
  • 【Wide Compatibility】USB drive supports Windows 7/8/10/11 / Vista / XP / Unix / 2000 / ME / NT Linux and Mac OS, also Supports USB 2.0 and 1.1 ports. USB Stick support TV, desktop, notebook computer, car, audio and other device. The USB Memory Stick is your great data storage and transfer companion with traveling and working.
  • 【Easy to use】usb memory stick is plug and play without any software installation. Just simply plug the Flashdrive into the port of your USB-compatible devices such as computer, laptop to start data storage or transmission.
  • 【What You Get】16 GB USB Flash Drive Thumb Drive, The default format of the usb storage flash drive is FAT32.

Plugins throw fatal errors after import

Compare the imported settings with the files installed on the destination. Restore the matching plugin and theme versions, verify PHP compatibility and temporarily disable the failing extension by renaming its directory if you need access to the dashboard. Do not treat a plugin fatal error as evidence that the database itself is corrupt.

Multisite sites are missing or redirect incorrectly

Confirm that all network tables were imported, that domain and path columns match the current network, and that the web server’s multisite rewrite rules are present. Use a network-aware search-replace only after identifying the intended sites and retaining a complete backup.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

phpMyAdmin or WP-CLI: which should you use?

Consideration phpMyAdmin WP-CLI
Interface Browser-based graphical interface SSH or terminal command line
Best fit One-off imports and administrators without shell access Repeatable migrations, automation and large files
Main operational risk Timeouts, upload limits or selecting the wrong database Running commands from the wrong path or with unintended credentials
URL changes Needs a serialization-safe plugin/tool or carefully designed SQL operation Built-in wp search-replace with dry-run and serialized-data handling
Database creation Usually performed separately in the hosting panel or server tool wp db import does not create the database; create it first

Choose phpMyAdmin when the dump is modest and your host exposes a reliable import screen. Choose WP-CLI when the file is large, browser limits are restrictive, or you need commands that can be reviewed and repeated. The safety requirements—correct target, current backups, matching files and post-import validation—are the same for both.

How to roll back

If validation reveals data loss or an incompatible environment, put the site back into maintenance mode. Restore the original database backup to the original database or a clean replacement, restore the corresponding WordPress files if they were changed, and revert wp-config.php to its saved version. Clear caches, test the original URL and review logs before reopening the site. Keep the failed imported database separately if you need to inspect it; do not overwrite the only rollback copy while troubleshooting.

A concise go-live checklist

  • Current database and complete file backups are stored outside the server.
  • The destination database and user exist, privileges work and wp-config.php points to them.
  • The SQL dump has been imported into the intended database and table prefix.
  • Matching themes, plugins, uploads and server configuration are present.
  • Any domain or path change was dry-run, reviewed and applied with serialization-aware tooling.
  • home, siteurl, login, media, menus, widgets, forms and plugin settings have been tested.
  • Permalinks and relevant caches have been refreshed.
  • Logs and normal traffic have been monitored before deleting rollback copies.

The Bottom Line

Import the dump into the MySQL database named by the destination wp-config.php, not into WordPress itself. Back up the live database and files first, use phpMyAdmin or wp db import according to your access and file size, perform any URL change with WP-CLI’s serialization-aware search-replace, and retain the rollback copy until the complete site passes testing.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Database BackupMySQLphpMyAdminWebsite MigrationWordPressWP-CLI

Leave a Reply

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

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.