mysql uses ip address

Problems with the Windows version of XAMPP, questions, comments, and anything related.

mysql uses ip address

Postby oldyork » 31. December 2016 20:37

Op - feel free to nuke the post. I didn't see an English version of the mysql list so I decided to take liberties.

I have an Apache server running as a virtual host. I'm trying to replicate a production environment on my local box. Works well, except for the site's use of mysql database connectors; they hard coded the host parameter as an ip address and not a name. Is there a way to accommodate the use of an ip address in the mysql? This is deprecated technology [ mysql_connect('123.123'123.123', $db_user, $db_pw) - I had to install the support module ] so there may be additional problems.

Xampp port is ApacheFriends XAMPP Version 5.6.15

Thank you
oldyork
 
Posts: 8
Joined: 29. December 2016 05:16
XAMPP version: 5.6.24
Operating System: win7

Re: mysql uses ip address

Postby JJ_Tagy » 31. December 2016 22:11

I'm pretty sure you can use ip or host. You probably want to make sure you use all dots (.) instead of '123.123'123.123'

Also, you will want to use mysqli instead of mysql to connect.
JJ_Tagy
 
Posts: 727
Joined: 30. January 2012 13:44
Operating System: Windows 10 Pro x64

Re: mysql uses ip address

Postby oldyork » 01. January 2017 03:30

Typo on the ip address. Sorry.

So, here's some more info. I've modified two files trying to remap the ip address.

\Windows\System32\drivers\etc\hosts
and
\xampp2\apache\conf\extra\httpd-vhosts.conf

With host names it worked find. Here are the additional entries I made. If you can think of a permutation, I've probably tried it. I'm wonder now it this isn't some mysql config problem. Again, take away the ip address, use a name, and everything is fine: (it's the entries with the ip addresses that fail. After any change in either of these two files, I cycled Apache and flushed the dns. Error message from connect attempt is:

mysql_connect(): A socket operation was attempted to an unreachable host

======================================================================

<VirtualHost *:80>
DocumentRoot "C:/xampp2/htdocs"
ServerName www.production.com
</VirtualHost>

<VirtualHost 123.123.123.123>
DocumentRoot "C:/xampp2/htdocs"
ServerName www.production.com
</VirtualHost>

====================================================================

127.0.0.1 localhost
127.0.0.1 www.mspfound.com # second server
123.123.123.123 localhost

or


127.0.0.1 localhost
127.0.0.1 www.mspfound.com # second server
123.123.123.123 www.mspfound.com
oldyork
 
Posts: 8
Joined: 29. December 2016 05:16
XAMPP version: 5.6.24
Operating System: win7

Re: mysql uses ip address

Postby Altrea » 01. January 2017 03:57

domain name resolution is a one way ticket. You can only resolve a name to an ip address, not an ip address to a name.
You cannot simulate that your computer does have a foreign ip address except you really configure your network card to have this ip address.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 8963
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: mysql uses ip address

Postby oldyork » 01. January 2017 04:10

You know I'm in no position to doubt you, and yet... it's software! :-) I am proceeding with some edits to obviate the need. However, I'll just mention that I see all kinds of virtual ip posts out there - none of which I can truly understand yet. But thank you and please don't take this post in the wrong way. I discuss with all respect here. Thank you for your input. I'd REALLY like to find a good link on this server/ip/dns stuff. I thought I knew enough. I surely don't.
oldyork
 
Posts: 8
Joined: 29. December 2016 05:16
XAMPP version: 5.6.24
Operating System: win7

Re: mysql uses ip address

Postby Nobbie » 01. January 2017 12:30

oldyork wrote:I'd REALLY like to find a good link on this server/ip/dns stuff. I thought I knew enough. I surely don't.


As your code is working with hard coded IPs, there is no DNS involved. DNS is a service to assign domain names to IPs. But IPs are IPs and Altrea is completely right, you MUST assign the IP (i.e. 123.123.123.123) to the network adapter which should run the server. There is no other way - or you have to edit the corresponding files and replace the hard coded IP either by another IP or by a name.
Nobbie
 
Posts: 9764
Joined: 09. March 2008 13:04

Re: mysql uses ip address

Postby oldyork » 01. January 2017 17:12

Happy New Year! Thanks for the post. My resolution for the year is network 101 and understand what is being said here. York - out.

http://httpd.apache.org/docs/2.4/vhosts/ip-based.html
oldyork
 
Posts: 8
Joined: 29. December 2016 05:16
XAMPP version: 5.6.24
Operating System: win7

Re: mysql uses ip address

Postby Nobbie » 01. January 2017 18:01



IP Based VirtualHosts do not help on your issue.
Nobbie
 
Posts: 9764
Joined: 09. March 2008 13:04

Re: mysql uses ip address

Postby Altrea » 01. January 2017 18:47

The question i am asking is, why do you need to use a different ip address?
Why don't you simply use your own one or a simulated domain name as everyone?
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 8963
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64


Return to XAMPP for Windows

Who is online

Users browsing this forum: Nobbie and 33 guests