Skip to content

Instantly share code, notes, and snippets.

@jaircuevajunior
Last active July 20, 2019 10:43
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jaircuevajunior/4b4e7a124495066b1335778dde5c0c52 to your computer and use it in GitHub Desktop.
Save jaircuevajunior/4b4e7a124495066b1335778dde5c0c52 to your computer and use it in GitHub Desktop.
Change/Migrate wordpress domain in MySQL

Find/Replace within dump method

This is a very simple method, and for me (as a SysAdmin) it's very practical as I usually make things through SSH terminal.

It's important to say that everything (including text inside posts) that matches the find string WILL BE REPLACED!

For me it's never been a problem so far, but one never knows

First we generate the dump itself, for example:

mysqldump -umyuser -pmypass mydatabase > mydumpfile.sql

Now the find/replace command

sed -e 's/myolddomain.com/mynewdomain.com/gi' mydumpfile.sql -i

And now reimport the dump, like:

mysql -umyuser -pmypass mydatabase < mydumpfile.sql

And that's all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment