开发者

PHP MySQLi query - "Permission denied" [duplicate]

This question already has an answer here: Connect DATABASE Er开发者_StackOverflowror TYPE: 2002: Permission denied (1 answer) Closed 3 years ago.

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.


I think the database user do not have sufficient permission to make particular operation on particular mysql table.


This isn't a permissions error. The client isn't able to get as far as connecting to the database, let alone trying to authenticate the user.

I suspect these problems will be being caused by either network problems (preventing the client/server machines from talking to each other) or the MySQL server process not running on the remote host.

The error code is documented here: http://dev.mysql.com/doc/refman/5.5/en/can-not-connect-to-server.html


Check The Permissions for the user that you are connected through

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜