OK, so I run MySQL on remote server.
So far we have tons of users they have a difficulties to understand that they need to use another IP address instead of 'localhost' in MySQL configuration for their scripts.
So I decided to find a solution so they can continue using localhost as MySQL hostname but PHP would understand that localhost is actually different IP address.
SO I edited /etc/hosts and set something like:
10.0.0.3 localhost
#127.0.0.1 localhost
Where 10.0.0.3 MySQL server IP.
Now When I do ping localhost I see that my localhost has 10.0.0.3 address. Very nice!
Unfortunately when I try to connect to this fake 'localhost' from PHP script, it gets ignored and it still tries to access local MySQL server (which is not installed at all).
I have restarted Apache after made changes to /etc/hosts. Moreover as I said 'ping localhost' gives 10.0.0.3 Ip , so Its OK.
But not for Apache/PHP. It is somehow possible to let Apache/PHP think that 'localhost' has value which is set on /etc/hosts ?
Different IP address for 'localhost' and MySQL
Moderator: General Moderators
Re: Different IP address for 'localhost' and MySQL
I think this is a very wrong approach to solve this "problem". Other software may rely on proper "localhost" resolving (i.e. 127.0.0.1)
Anyway: try to add
in your /etc/host.conf file
Anyway: try to add
Code: Select all
order hosts, bindThere are 10 types of people in this world, those who understand binary and those who don't