SQL Server: database owner SID issue

If you restore a database on a different SQL Server you may see the following error message:

The database owner SID recorded in the master database 
differs from the database owner SID recorded in database...

The solution is to change the authorization on the database to a known SQL account:

alter authorization on database::{databasename} to {username}

Simply replace the {databasename} and {username} with the appropriate names; the brackets should not appear in the SQL query.