php5.2.17 mysql,用户'SYSTEM'@'localhost'的访问被拒绝(PHP 5.2.17 + mySQL 5.5.8 + Windows 7)...

I wanted to test a script written for PHP 5.3.5 (installed as Apache module) in PHP 5.2 environment.

I installed a fresh copy of Apache 2.0.64 and PHP 5.2.17 and configured it EXACTLY as I had configured PHP 5.3 before. Except I did copy libmysql.dll into Apache bin directory (PHP 5.3 doesn't have this file anymore).

Both servers are configured by hand (not a XAMPP versions or something) and access the same locally installed mySQL Server 5.5.8. Both servers are running as Windows Server under the system account.

PHP 5.3 works perfectly, PHP 5.2 returns an error:

Warning: mysql_connect() [function.mysql-connect]: Access denied

for user 'SYSTEM'@'localhost' (using password: NO) in C:\Tools\htdocs\myscript.php on line 33

The SQL-user I am using is hardcoded in PHP code ant it is not SYSTEM@localhost. SYSTEM seems to be a Windows account the Apache is running under. (If I start the Apache from the Administrator account, the message changes to Administrator@localhost.)

The default user (with a name '') was deleted on my SQL-Server. If this empty-user exists, the PHP 5.2 connects to the database successfully, but fails on the database selection (mysql_select_db) because of permissions.

解决方案

If the sql.safe_mode (NOT the PHP safe mode) in on in the php.ini, PHP is always using the script owner to connect to the SQL server and not the user specified in mysql_connect().

I mixed up the property safe_mode and sql.safe_mode during the configuration and it cost me 6 hours!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值