I will allow myself to expand on Ricks answer as there are a few ways to change old domain to new domain and each might be helpful depending on your situation.
1) use the Better Search and Replace plugin https://wordpress.org/plugins/better-search-replace/ plugin as suggested in the answer above.
2) use Database Search and Replace script https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
You can easily upload it to your server via FTP and then delete once you replace the domain names.
It does not require WordPress to run just PHP and MySQL (so this can be plus or minus depending on your use case i suppose).
3) if you have access to WP CLI (WordPress command line interface) you can use the wp search-replace
command to update the domain https://developer.wordpress.org/cli/commands/search-replace/
With WP CLI installed on your server already, this is the quickest way to do that i think and does not require installing anything.
4) do it manually in the database, but with so many tools available i would recommend selecting a solution from #1 to #3.