Change main domain of wordpress site

Ideally you should be able to do this in the WP admin however you might have trouble logging in even as the site is trying to force the set domain. So in this case it might be easier to fix the db:

UPDATE wp_posts SET
 guid = REPLACE(guid, '', ''),
 post_content = REPLACE(post_content, '', '')
UPDATE wp_options SET
 option_value = REPLACE(option_value, '', '')

Note thought that some plugins – the ones with integrations to external services – might need to be repaired but normally that should be no problem.