Rewrite database urls

Try this plugin: http://wordpress.org/extend/plugins/search-and-replace/ – It helped me dozens of times.

Or try this query:

UPDATE tablename SET tablefield = replace(tablefield, "findstring", "replacestring");

Or try this method, dump the database, open the SQL file, do a find and replace in a text editor then reimport it.

Take care to backup your database prior to making any operations and changes!