0

The name database host, how the name indicates "the server that hosts the database", should be the server ip, that hosts that database. I don't see any relation of it with the scripts that try to access it. But conversely, what I see the explanation mostly is :

"As long as the program ( php/.net scripts ) are on the same server as the database, which is the case with our servers, you will want to use 'localhost' as the database hostname.If you are needing to test an external connection, you can use the domain name (if pointed to our nameservers) or the server IP address"
It means, the scripts location decide the "database-host" ?

So, does that mean this terminology is confusing ? Also, why something called database-host needs to be configured ? What is it's importance ?

2
  • 2
    The scripts that need to access a database need to know where to make a connection to to access the MySQL/Postgress/MSSQL process that manages the actual storage. This is what gets filled into the "database-host" configuration field. Jan 11 '16 at 11:37
  • 4
    "does that mean this terminology is confusing?" - no it's not. Looks like an English issue more than anything else. The database host name is the name of the host that has the database. That's all, there's no magic or confusion. "localhost" is just a special name designating the current server.
    – Mat
    Jan 11 '16 at 12:11
6

It is not unusual for the database to be on one server and the scripts to be on another server.

In this situation, it is necessary for the script to know the name of the server that holds the database. This name is sometimes known as the "database host name" because it is the name of the server that hosts the database.

Localhost is a special name that means "the name of the server the script is running on". If you use this special name, then you don't need to worry if someone renames the server. Likewise, your script will work fine on another server if the database is also on that other server.

2
  • On Windows, LocalHost is just an entry in the HOSTS file that maps to the IP address 127.0.0.1. Domain names are mapped in a similar fashion. Jan 11 '16 at 16:08
  • 1
    Ok, yes, thanks for explanation. I was confused thinking other way round. As, why a script file location decides which IP is database host, but not the database itself. But yes, it makes sense, because, database host needs to be mentioned inside the script file as configuration info. So, database host name is relative to the script file location.
    – Vishwas
    Jan 11 '16 at 18:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.