I can no longer connect to MySQL on my local machine using PHP since I upgraded to 4.2.0.
My PHP file still says:
$db = mysql_connect("localhost", "username", "password");
as it always has.
Now, I'm on a LAN but don't let that confuse the issue, my machine is running its own Apache installation and I am accessing the files in a web browser on my machine at location http://127.0.0.1/~lee/
the same way I always have. Only since I upgraded my PHP I get this error:
Warning: Host 'localhost.xxxxxxxx.co.uk' is not allowed to connect to this MySQL server in /Users/lee/Sites/development/Lutonflooring(PHP)/index.php on line 2
What I don't understand is where it's getting the domain name from. The xxxxxx *is* the company's ISP, but where the hell is my computer getting this information from? It's not in my network settings, I am just a number on a LAN which is just a standard 192.168.x.x setup.
Any clues would be appreciated.
PHP 4.2.0 and MySQL connect problem
Moderator: General Moderators
-
leenoble_uk
- Forum Contributor
- Posts: 108
- Joined: Fri May 03, 2002 10:33 am
- Location: Cheshire
- Contact:
You could add privileges for that user
i.e. from the MySQL command line type logged into the mysql instance
mysql> grant all privileges on *.* to username@localhost.******.co.uk identified by 'password';
mysql> flush privileges;
Although it doesn't solve where the ***** came from it should get you working again.
Mike
i.e. from the MySQL command line type logged into the mysql instance
mysql> grant all privileges on *.* to username@localhost.******.co.uk identified by 'password';
mysql> flush privileges;
Although it doesn't solve where the ***** came from it should get you working again.
Mike
-
leenoble_uk
- Forum Contributor
- Posts: 108
- Joined: Fri May 03, 2002 10:33 am
- Location: Cheshire
- Contact:
Thanks but...
cheers for the suggestion, I had thought of that already. It's a workaround but doesn't solve the problem as to why it's started happening.
UPDATE: If I reboot without my network cable plugged in, everything works fine. So the [@xxxxxx.co.uk] is coming from the network somehow. Something has changed in version 4.2.0 which is different to previous versions. I running Mac OSX 10.1.4, MySQL 3.23.39 PHP version 4.2.0, Apache 1.3.23
My guess is that there may be something in PHP.ini which may control this. It's odd though that if I unplug my cable after rebooting and attempt to just restart apache it does not fix the anomole as it still persists with the localhost@xxxxxx.co.uk rubbish.
Anyone?, anyone?
UPDATE: If I reboot without my network cable plugged in, everything works fine. So the [@xxxxxx.co.uk] is coming from the network somehow. Something has changed in version 4.2.0 which is different to previous versions. I running Mac OSX 10.1.4, MySQL 3.23.39 PHP version 4.2.0, Apache 1.3.23
My guess is that there may be something in PHP.ini which may control this. It's odd though that if I unplug my cable after rebooting and attempt to just restart apache it does not fix the anomole as it still persists with the localhost@xxxxxx.co.uk rubbish.
Anyone?, anyone?
- sam
- Forum Contributor
- Posts: 217
- Joined: Thu Apr 18, 2002 11:11 pm
- Location: Northern California
- Contact:
Code: Select all
grant all privileges on *.* to username@localhost identified by 'password';Cheers Sam
-
leenoble_uk
- Forum Contributor
- Posts: 108
- Joined: Fri May 03, 2002 10:33 am
- Location: Cheshire
- Contact:
It works...
'tis true! It works but I can't see why it should. All you have to do is re-grant all the privileges to get it working again. I already got this from Marc at Entropy, the guy who makes the packages for OSX. I see no reason why the upgrade of PHP should affect the permissions in mysql since there's no guarantee you would even have mysql installed. MySQL still worked at the command line just as before. PHP worked in every other way except connecting to MySQL. Odd, but at least it's been solved. I just hope it becomes a documented bug so no-one else has to go through similar hoops trying to solve this issue.
thanks again though.
thanks again though.
Localhost vs loopback
I have a question on this same subject.
I have granted all privileges to both root and mysql users @ localhost.
If I connect to mysql from the shell by issuing the following command:
shell> mysql -h localhost -u mysql -p
it works fine (same if I use the root user).
Now, if I type the following statement in a php page:
mysql_connect("localhost", "mysql", "password");
I get the following php message:
Warning: Host 'loopback' is not allowed to connect to this MySQL server
Strange, because I entered localhost as host name, not loopback.
Then I tried to connect to mysql from the shell specifying loopback as host:
shell> mysql -h loopback -u mysql -p
It failed. So, I granted all privileges to mysql@loopback and now also the php code worked fine.
It seems that the localhost specified in the mysql_connect has been somewhere replaced by loopback.
Does any of you have an explanation ?
Thanks,
Luca
I have granted all privileges to both root and mysql users @ localhost.
If I connect to mysql from the shell by issuing the following command:
shell> mysql -h localhost -u mysql -p
it works fine (same if I use the root user).
Now, if I type the following statement in a php page:
mysql_connect("localhost", "mysql", "password");
I get the following php message:
Warning: Host 'loopback' is not allowed to connect to this MySQL server
Strange, because I entered localhost as host name, not loopback.
Then I tried to connect to mysql from the shell specifying loopback as host:
shell> mysql -h loopback -u mysql -p
It failed. So, I granted all privileges to mysql@loopback and now also the php code worked fine.
It seems that the localhost specified in the mysql_connect has been somewhere replaced by loopback.
Does any of you have an explanation ?
Thanks,
Luca