If the target server has wp-cli installed, you can use the following command.
wp search-replace 'https://www.from.com' 'https://www.to.com' --dry-run
The “–dry-run” makes sure no changes would be made, so you can do a test run first.
When you are ready to make the replacement, simply remove the “–dry-run” and run the command again.
If you have no ssh access or wp-cli is not available, another easy way would be specifying the url in the wp-config.php first, so you can access the site.
define( 'WP_HOME', 'http://example.com' );
define( 'WP_SITEURL', 'http://example.com' );
Adding the two lines above in the wp-config.php somewhere.
Once you can access the site and login, then install search and replace plugins such as https://en-ca.wordpress.org/plugins/better-search-replace/, and replace all occurrences of the old domain with the new one.