-1

I have Mac OSx (mountain Lion), Windows 7, Fedora 17 installed on my Macbook pro, and I can't connect to the local host on any of them, it always tells me can't connect.

I'm learning mysql and from the tutorials, I guess I have to be connected to my localhost to create databases and stuff, but do I have to install something first for it to work?

P.S. - for mac, I don't have the option "web sharing" to enable in the system preferences. - for windows, I tried to enable IIS, but it gives me an error ... I also tried to work it out using the cmd.exe but it just doesn't work as well. - for fedora, I'm new to it, but I just installed and I have no idea why it's not working.

3
  • 1
    To connect to "localhost" there must actually be something running. If its SQL your connecting to, you have to actually have an SQL server running Nov 25, 2012 at 6:09
  • Can you provide the actual commands you're trying to use, and for each command describe what you're trying to do?
    – Johnnie
    Nov 25, 2012 at 6:47
  • Have you started the mysql server on any of the systems before trying to connect?
    – ott--
    Nov 25, 2012 at 17:18

2 Answers 2

0

A connection to the localhost pseudo-domain may be acquired by directing a client at the localhost domain or at the IP address it represents.

E.g:

firefox http://127.0.0.1/
mysql -h localhost

These connection attempts will result in an error such as "Remote host refused the connection" when there is nothing running (listening) on the ports the client is connecting to. In the above example the ports in question would be 80 (HTTP) and 3306 (MySQL).

0

Unlike the connections on your physical network cards, that can be active/inactive, shared, and have to be properly set up, a localhost connection is just a shortcut that points to your own machine. It doesn't "stay active all the time" and you don't have to "connect to it" for longer than the period of time required for the commands to be executed.

When you use your browser to view a remote webpage (let's say Facebook), you don't have to setup a connection to the website on your OS control panel. You just inform the destination on the browser address bar. When you try to connect to localhost, the process is the same. To the client software, it doesn't matter if the server is local or not, if you try yo view a webpage on localhost, your browser will behave the same as if it was an external server, it's just the IP that's different.

The localhost address just points the destination to your own computer. You don't have to configure anything extra in terms of network cards or network sharing. The commands you try to execute will only be executed if you have a server present on your own machine. So, if you want to point your browser to localhost, you need a web server running on your machine. If you want to execute MySQL commands, you need a mysql serveron your machine. If you want to execute PHP code, you need a PHP interpreter installed on your machine. The protocol itself doesn't matter, it will be determined by the port the client tries to connect.

To simplify this process A LOT, I recommend you install a WAMP (or MAMP, or LAMP) package. They install Apache, MySQL and PHP in a single package. On windows, Wampserver is a good one.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .