wp-cli: Search Replace not working for domain name change
Cloning a site from production and moving to development environment so I’m going from site.company.com to sitedev.company.com
Once the database has been moved to the development domain, every instance of site.company.com must be changed to sitedev.company.com
I’m currently using this tool which works great but I’d like to be able to use wp-cli to add this functionality to a script.
After moving a site, though, the following returns an ‘unable to connect to database’ error wp search-replace 'site.company.com' 'sitedev.company.com'
The tool mentioned above uses the contents of the wp-config file to connect to the database. If I drop it on the dev server and walk through the steps manually, it works with no problems. but based on the error, it seems like wp-cli does it differently. So is there something else I should be doing so it can connect to the database?
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 27 (7 by maintainers)
I now it is closed.
I had the same issue, the problem was that you have to remove quotes:
Change it for
wp search-replace site.company.com sitedev.company.comAw snap. that did it @rodrigoprimo
This is what ended up working:
Thanks for all the help guys.
Then add
--all-tables-with-prefixor--all-tablesflags - see documentation