I have always relied on this process:
https://codex.wordpress.org/Moving_WordPress
Notice the statement "If you do a search and replace on your entire database to change the URLs, you can cause issues with data serialization".
I've used a couple of different plugins to overcome that problem, including this one mentioned in that codex article:
https://wordpress.org/plugins/velvet-blues-update-urls/
I have also successfully used this plugin for sites that are small enough (Files storage size): https://wordpress.org/plugins/duplicator/
It does all the work for you.