Telling MySQL what its IP address is

oboeguy

Diamond Member
Dec 7, 1999
3,907
0
76
I've got this MySQL DB which now others on the LAN need to see. MySQL, though, believes its IP address is the loopback address b/c it thinks the computer host name is "localhost". I tricked MySQL by changing the hosts file (local host now points to 192.blahblahblah), which seemed easiest for now. So how do I fix this for real? There must be a simple way that I've missed. I'm using the admin package that MySQL suggests, MySQL Administrator. Please pardon my noobishness...:confused:
 

oboeguy

Diamond Member
Dec 7, 1999
3,907
0
76
Sorry, forgot to mention, Windows. I searched for "localhost" in my.ini and had no luck.
 

znaps

Senior member
Jan 15, 2004
414
0
0
I think you're confused about something. If your computer really is named "Localhost" then change it to something more sensible.
 

oboeguy

Diamond Member
Dec 7, 1999
3,907
0
76
Nah, the computer isn't named localhost, I just suck at explaining this situation. The computer name is a pretty weird string, as you might expect in an office LAN. MySQL was serving as "localhost" with IP address "127.0.0.1" until I changed the hosts file definition of "localhost".

There's apparently something called "bind-address" as an option but I don't understand how to use it in my.ini and still be able to connect to MySQL from the admin tool.
 

WannaFly

Platinum Member
Jan 14, 2003
2,811
1
0
Do you have more then one NIC in the machine? If not, then it uses whatever IP address the NIC has, if you ha ve more then 1, well, i dont know.
 

oboeguy

Diamond Member
Dec 7, 1999
3,907
0
76
Just one NIC. I think perhaps I am not explaining myself. How do I get MySQL to think it is running as anything other than "localhost"? and then how do I get the admin tool to be aware of the update? Thanks again.
 

znaps

Senior member
Jan 15, 2004
414
0
0
Forget about localhost then. If others on the LAN need to connect to MySQL on that machine then they just go by the machine name, or IP address. Simple as that. You shouldn't need to configure MySQL in any way.
 

oboeguy

Diamond Member
Dec 7, 1999
3,907
0
76
OK, but then why did it not work until I did my little trick with the hosts file? I swear the way it went down is that on the client on the LAN I set up a DSN with my machine's LAN IP address as the server IP and it couldn't establish the connection until I made "localhost' on my machine point to my LAN IP address.

(<-- confused no0b)
 

znaps

Senior member
Jan 15, 2004
414
0
0
If you post the conifguration (screenshots, cfg files whatever) from your clients and server it might be more clear.
 

oboeguy

Diamond Member
Dec 7, 1999
3,907
0
76
OK, where do I put that? I imagine in the [mysqld] section, right? Do I put anything in the client section? BTW, I have some screen shots I guess I could post to finally clear things up.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: oboeguy
OK, where do I put that? I imagine in the [mysqld] section, right? Do I put anything in the client section? BTW, I have some screen shots I guess I could post to finally clear things up.

If you're talking about my post, it's part of the startup command. mysqld --bind-address blah bah blah.

I'm sure there is an option in the configuration file, but I'm too lazy to look it up for you.
 

oboeguy

Diamond Member
Dec 7, 1999
3,907
0
76
Here's the deal, I can't start MySQL (installed as an Service in XP Pro, should have mentioned that) when I use the --bind-address switch in my.ini. Ideas?
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: oboeguy
Here's the deal, I can't start MySQL (installed as an Service in XP Pro, should have mentioned that) when I use the --bind-address switch in my.ini. Ideas?

In the service properties, you might be able to include the bind-address flag under "Start parameters."

Or you could LOOK AT THE DOCUMENTATION.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Since I'm such a nice guy and the documentation sucks:
That's what the following option to mysqld is
for:
--bind-address=IP Ip address to bind to
which can be entered into my.cnf as
follows:
[mysqld]
bind-address=192.168.1.1
or similar.

If you're going to use F/OSS software, get used to reading the documentation.
 

oboeguy

Diamond Member
Dec 7, 1999
3,907
0
76
Dude, I *always* RTFM. However, I was unable to find that little snippet you quoted. I'll give it a whirl, thanks!
 

oboeguy

Diamond Member
Dec 7, 1999
3,907
0
76
Hey thanks for the help monkey. I passed the command-line argument to the service and it works beautifully now.

FYI, I'm one of those people who has written documentation for an OSS project, so I know how good or lousy it can be. :D
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
I found the second snippet (the my.cnf one) by googling for: my.cnf +"ip address"

Two minutes later, I found the solution.

The first suggestion I gave you came from their documentation, but it probably took me longer to find since it's horribly laid out. :beer: