Running WordPress Locally with WP-CLI
Quick reference for setting up a local WordPress instance and importing a database dump using WP-CLI.
Create a Site in Local
Click + → name your site → “Preferred” setup → set credentials → Create Site
Local provisions WordPress automatically
Import a Database Dump
Right-click the site → Open Site Shell
Reset the database first (fresh installs already have tables):
wp db reset --yes
Then import:
wp db import /path/to/your-dump.sql
Drag the
.sqlfile into the terminal to paste its full path instead of typing it💡 Don’t use Adminer for large dumps (>100 MB) — PHP memory limit will choke. WP-CLI handles them fine.
Fix URLs After Import
The dump contains the production domain; you need to search-replace it:
wp search-replace 'https://old-domain.com' 'http://yoursite.local' --all-tables
--all-tablescatches serialised data in custom tablesThen force the core options:
wp option update siteurl 'http://yoursite.local' wp option update home 'http://yoursite.local'
Verify:
wp option get siteurl wp option get home
Still Redirecting to Production?
The browser caches 301 redirects — the database is probably fine
Test in a private/incognito window first
If it works there, clear browser cache for that domain
Common Gotchas
Table already existserror → old database, you forgotwp db reset --yesfirstDISALLOW_FILE_EDIT already definedwarning → harmless, ignore itLarge dumps fail in Adminer or phpMyAdmin→ use WP-CLI instead