WordPress Admin Redirects to Previous EC2 Public DNS

I successfully installed WordPress 3.5.2 on my Amazon EC2 Amazon Linux AMI micro instance. I was able to log into the admin backend, and view my front end blog post.

However, after stopping and restarting the micro instance (in an effort to minimize the charges), I was given a new Public DNS address. I restarted the httpd and mysqld services. When I tried to access my admin backend with this new URL, I kept getting redirected to the previous Public DNS which no longer exists

Read More
http://ec2-xx-xxx-x-xxx.compute-1.amazonaws.com/mysite/wp-admin

I cleared Chrome’s cache. I could not find the site url among the configuration files. I’m not sure what to do. Any assistance will be appreciated. Thanks in advance.

Related posts

Leave a Reply

3 comments

  1. WP-Admin will redirect to the siteurl option set in the wp_options table. This is generally the row with ID 1, but you can get it with:

    SELECT * FROM wp_options WHERE option_name = "siteurl";
    

    You can update it with:

    UPDATE wp_options SET option_value = "http://your-new-site-name.com" WHERE option_name = "siteurl";
    
  2. To make the accepted answer more complete, i suggest you all run the following mysql queries:

    UPDATE wp_posts SET guid = replace(guid, 'http://www.old-domain.com','http://www.new-domain.com');
    
    UPDATE wp_posts SET post_content = replace(post_content, 'http://www.old-domain.com', 'http://www.new-domain.com');
    
    UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');
    

    and an altered version of the one given in the accepted answer:

    UPDATE wp_options SET option_value = replace(option_value, 'http://www.old-domain.com', 'http://www.new-domain.com') WHERE option_name = 'home' OR option_name = 'siteurl';
    
  3. Adding the answer with more details. This will be helpful for people who are new to MySQL.
    From the command window access root of MySQL.

     mysql -u root -p
    

    Then, choose the database you have already created(wordpress is my dbname):

    use wordpress
    

    Next, execute the command:

    SELECT * FROM wp_options WHERE option_name = "siteurl";
    

    Which will show what is in the table as given below.
    enter image description here

    Finally, modify the field with below command.

    UPDATE wp_options SET option_value = "http://your ip" WHERE option_name = "siteurl";