Sunday, 24 May 2015

Migrating AWS EC2 WordPress install to micro instance issues

After migrating my AWS (Amazon Web Services) EC2 instance from small to micro - in order to stop getting charged for it. I found all the urls were pointing to the old domain.

On the face of it, this looks like a Linux hostname issue, and I spent a while setting up the ssh access to the box and searching for the hostname or server name - what I found turned out to the be private hostname / ip address, and therefore wasn't causing the issue.

I suddenly had a brain wave that maybe it was stored in the DB.

I then found I could login to the DB using the 'mysql --user=username --password=password' command. This allowed me to login.

I then found the schema for wordpress;

Which I made a guess that it was the wp_options table.

I then did select * from wp_options, and put the result in a text editor and searched for the old domain name, and there it was under the option_name 'home' and 'siteurl'.

So I then used the following two command to update those values;

mysql> select * from wp_options where option_name = 'siteurl';
| option_id | option_name | option_value      | autoload |
|         1      | siteurl       | ***URL**              | yes          |

update wp_options set option_value='http://newdomainame/wordpress' where option_name='home'

update wp_options set option_value='http://newdomainname/wordpress' where option_name='siteurl'

And ran a commit for luck, and it all started working again.

No comments:

Post a Comment