Mobile app version of vmapp.org
Login or Join
Pierce454

: How would I know the hostname of my hosting? I have a website and I am trying to make a database connection. I am in MySQL but I don't see any information related to the hostname. localhost

@Pierce454

Posted in: #WebHosting

I have a website and I am trying to make a database connection. I am in MySQL but I don't see any information related to the hostname. localhost worked for me but I don't know the logic behind it. Please guide.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Pierce454

1 Comments

Sorted by latest first Latest Oldest Best

 

@Karen161

If you're wanting information on the meaning of localhost you've probably put this question in the wrong place. That question is more of a networking type question. Unfortunately, serverfault would probably consider this question as off topic too so I'll just go ahead and answer it for you and see what happens...

localhost is an alias for the current computer. It will resolve to the IP address 127.0.0.1. 127.0.0.1 is what is known as a loopback address. A loopback address is one which is never routed or accepted by remote computers it is therefore only valid to the local machine.

If you were connecting to another computer then you would use the hostname or IP of that computer in place of localhost. MySQL uses TCPIP for all remote connections (which is good for us because that is the same network protocol as is used on the rest of the Internet).

If you are making a website and that website will be hosted on the local machine as well then just by connecting through localhost you know you'll be OK. If you website is somewhere else then you'll need to configure it for remote access if you want your site to use it. The way to do that has been answered a lot so I'll just link to it: stackoverflow.com/questions/10835676/how-to-enable-root-access-to-remote-when-configure-mysql-instance
EDIT: When giving a hostname you will not add anything to it. If your site was sample.com, then you should only use that. Do not use sample.com because that is not valid. You want a domain name NOT a URL. The http part is a protocol specifier; MySQL uses it's own protocol (built on the TCPIP stack) which is the default and only protocol it knows. Also, you would ONLY put before your domain name IF you also have a DNS alias setup which points sample.com to sample.com.

EDIT2: In order for me to tell you exactly WHY what you've done didnt' work I'd need to know specifics. Once you knew those specifics I'd imagine you'd have no reason to ask this question. What you'll need is the information your web host has provided about the MySQL server. Usually, it is located on the same server as the website but the better hosts will provide a separate server for your DB. The exact information you'll need is going to be in an email they sent you when you signed up as well as a FAQ or Help section of their site. If you have a dedicated server you may be responsible for setting up your own MySQL instance on your server. In that case the hostname is going to be the same as your servers' hostname.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme