This is quite simple and comes pre-configured in most scripts and applications that you install within your hosting account. Therefore, it's not something that you should need to change or worry about.

The MySQL hostname for databases to connect is almost always localhost, unless specified otherwise.

If for some reason the above hostname doesn't work, you can use the local IP address 127.0.0.1 alternatively, although it's not recommended.

Only if the database is hosted on a remote MySQL server or cluster, other than the one where the script/application is installed, you would need to use the remote server's hostname or IP address instead, which would need to be whitelisted in cPanel under Databases -> Remote MySQL® first.

Updated by SP on 13/01/2023

Was this answer helpful? 274 Users Found This Useful (591 Votes)