Im using PHP MySQLi to connect to MySQL and sometimes doing query i get error:
"Permission denied" error code: 2002.
The strange thing is that it happens for different query's and totally unpredictable. For example it might happen on third query after first two executed correctly.
I know it is not problem with MySQL because i moved it from one server to another and problem still persists. Most likely problem with PHP or interconnection between PHP and MySQL servers (they're on different machines)
Anyone got ideas?
EDIT:
query what gets "Permission denied" works if i restart script - its not permissions problem
ERROR:
[23-Apr-2011 19:00:02] PHP Warning: mysqli::mysqli() [mysqli.mysqli]: [2002] Permission denied (trying to connect via tcp://xxx.xxx.xxx.xxx:3306) in /home/.../DB.php on line 19
[23-Apr-2011 19:00:02] PHP Warning: mysqli::mysqli() [mysqli.mysqli]: (HY000/2002): Permission denied in /home/.../DB.php on line 19
Same things happened on my environment. And the cause was SELinux.
You might be able to connect the database by executing php from command line while you might not by executing on the web server.
In my case, I turned off SELinux.
# setenforce 0
Or you have to set up SELinux correctly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With