-1

We have a Wordpress .sql backup which we restored on a linux box. Now we want to log in to the admin console and export the site as XML.

Unfortunately, the wp-login.php redirects to the old deprecated domain name.

Perhaps there is an /etc/hosts entry I can add? Or is there a way around the login page?

TIA, Bertrand

Quadmore
  • 33
  • 1
  • 6

2 Answers2

1

You'll need to get into the MySQL database and update the siteurl option:

mysql -u wordpressuer -p wordpressdbname 
Enter password: (password)
mysql> update wp_options set option_value='http://new.url.name.com' where option_name='siteurl';
exit;

This should then allow you to log in and change any other options.

See the WordPress codex for more information:

https://codex.wordpress.org/Changing_The_Site_URL

eric.green
  • 385
  • 1
  • 4
0

WordPress sites store their own URL in their database, so moving them can be a pain. You can actually overwrite this, by adding these two constants to wp-config.php:

/** Settings to keep this working on any domain name */
define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST']);
define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST']);

or, if WordPress is installed in a subfolder called blog:

/** Settings to keep this working on any domain name */
define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] . '/blog');
define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/blog');

This is much easier than editing the domain names in the database, as WordPress stores a lot of its config settings in the database in PHP serialize format, which is not intended to be edited by hand.

These settings will get the site basically working in its new location, and will certainly allow you to log in. However, WordPress also stores internal links (to images, other pages, etc.) as full URLs. So now you need something to scan over your database to find such links and update them for the new site location. You could, again, do this by hand, but it’s a pain, so I used a plugin called Velvet Blues Update URLs*.

This kind of thing is useful even if you’re not changing the domain name: just a move from HTTP to HTTPS can necessitate it.


* Velvet Blues is a commercial company. I am not affiliated with them in any way, and know nothing about them, except that this plugin works a charm.

TRiG
  • 1,167
  • 2
  • 13
  • 30