6 AnswersNew Answer
If you are using phpMyAmin, you can export the database and import it again on your new server as described here: https://www.techrepublic.com/blog/smb-technologist/import-and-export-databases-using-phpmyadmin/ You also need to change the login data of the database in the code if it is different from your old one. I think you can copy paste the rest of the code, but you might need to change a few links.
If your website is on a VPS I think transfering is easier than shared hosting. For example in sql server you can even detach the whole database from server and move the .mdf and log files to another server and then attach it again on the new server. But in shared hosting you have a control panel and you don't have direct access to server so look at the control panel and check db options. For example maybe you can download db or get a full back-up. If you want to transfer the website to a new server on the same network of current host provider I think it's not a problem at all, they do that for you to keep you as a customer. In the worst situation you may contact to host provider.
I restored the database, i changed the sql settings( database name as it came after restore,new username&password) on the configuration file. That’s all, right?
I think so. Just try it and you'll see whether it works.