I had a hard trying to change my WordPress domain name especially if this one is a WordPress Multisite. I ended with "Error Establishing a Database Connection in WordPress" error although the credentials are correct. Turns out it is a problem in the database, I had to log in to phpMyAdmin in order to change the site URL to the new one.
Today, I can guide through the steps that I did in order to change a WordPress Multisite domain name. What you need is to have WP CLI on your machine.
Step 1: Change your Vhosts configuration if you use Nginx or Apache server. Then restart the server.
Step 2: Run WP Search-Replace to change the domain name
wp search-replace 'old.domain.com' 'new.domain.com' 'wp_*'
If you encounter the error "Site not found", you can add this parameter to the command
In order to know how many changes that will be made, you can add
After that, you can test your new domain. If you are testing on your local, please edit your hosts file.