Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seguelador/4cb75ef064136885614d36176c47dbd9 to your computer and use it in GitHub Desktop.
Save seguelador/4cb75ef064136885614d36176c47dbd9 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