Migrating a WordPress site between two domains. Egg before the chicken?

Problem
You’ve setup a WordPress site on http://staging.domain.com with some initial content and you’re migrating it to  http://www.domain.com. When you attempt to login into WordPress admin, you’re redirected to your staging site (staging.domain.com).

Why is this happening?
Oops. Remember to change values in ‘General settings’ for ‘WordPress address’ and ‘Site address’ before you migrate the site.If you forget, these values can be changed after migration.

Solution
Login to mysql (or other) database and run the following sql:
update wp_options set option_value = 'http://www.domain.com' where option_name in ('home','siteurl');