用户'SYSTEM'@'localhost'的访问被拒绝(PHP 5.2.17 + mySQL 5.5.8 + Windows 7) [英] Access denied for user 'SYSTEM'@'localhost' (PHP 5.2.17 + mySQL 5.5.8 + Windows 7)

查看:139
本文介绍了用户'SYSTEM'@'localhost'的访问被拒绝(PHP 5.2.17 + mySQL 5.5.8 + Windows 7)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在PHP 5.2环境中测试为PHP 5.3.5(作为Apache模块安装)编写的脚本.

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

我安装了Apache 2.0.64和PHP 5.2.17的新副本,并对其进行了完全一样的配置,就像之前配置PHP 5.3一样.

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).

这两个服务器都是手动配置的(不是XAMPP版本或其他东西),并且可以访问相同的本地安装的mySQL Server 5.5.8.两台服务器都在系统帐户下作为Windows Server运行.

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完美运行,PHP 5.2返回错误:

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

我正在使用的SQL用户是用PHP代码硬编码的,而不是SYSTEM@localhost. SYSTEM似乎是运行Apache的Windows帐户. (如果我从管理员帐户启动Apache,则消息将更改为Administrator@localhost.)

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.)

默认用户(名称为")已在我的SQL Server上删除.如果此空用户存在,则PHP 5.2将成功连接到数据库,但由于权限的原因,数据库选择(mysql_select_db)失败.

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.

推荐答案

如果php.ini中的 on 中的sql.safe_mode(不是PHP安全模式),则PHP始终使用脚本连接到SQL Server的所有者,而不是mysql_connect()中指定的用户.

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().

在配置过程中我混用了属性safe_modesql.safe_mode,这花了我6个小时!

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

在此处找到了答案: http://www.php. net/manual/de/ref.mysql.php#72632

这篇关于用户'SYSTEM'@'localhost'的访问被拒绝(PHP 5.2.17 + mySQL 5.5.8 + Windows 7)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆