After migrating you have not only to worry about the site's URL (like WP_SITEURL and WP_HOME), but for every single link you use in your posts and pages that targets one of your own posts and pages. They will all direct to the wrong URL.
My advice is to always use a dedicated tool for that and follow what is written on WordPress.org about that topic. Even there, see under "Changing Your Domain Name and URLs", they recommend a "Search and Replace for WordPress Databases Script" to safely change URLs.
So my advice would be to not use PHPMySQL for that, but a dedicated script. But if you insist on PHPMySQL, then go with sorrow poetry's answer, but do not forget links inside your posts and pages, which you can both find in wp_posts.