Access denied for user "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 an Apache module) in a PHP 5.2 environment.

I installed a new copy of Apache 2.0.64 and PHP 5.2.17 and configured it EXACTLY, as I was setting up PHP 5.3 before. In addition, I copied libmysql.dll to the Apache bin directory (PHP 5.3 no longer has this file).

Both servers are manually configured (and not XAMPP versions or something else) and gain access to the same locally installed mySQL Server 5.5.8. Both servers are running Windows Server under a system account.

PHP 5.3 works fine, 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'm using is hard-coded in the ant PHP code, this is not SYSTEM@localhost . The system seems to be the Windows account that Apache runs on. (If I started Apache from the administrator account, the message will change to Administrator@localhost .)

The default user (with the name ``) was deleted on my SQL server. If this empty user exists, PHP 5.2 successfully connects to the database, but the selection of the database ( mysql_select_db ) mysql_select_db due to permissions.

0
source share
2 answers

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

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

The answer was found here: http://www.php.net/manual/de/ref.mysql.php#72632

+2
source

The problem is that you did not provide the correct username and password for mysql_connect . Instead of leaving them empty (and letting PHP use the default user), specify the actual username and password that were added to MySQL using GRANT (or phpMyAdmin or any other client client).

Allowing authentication without a password is a huge no-no. Allowing administrator access without a password is just awful. Instead, create limited user accounts for all of your programs. Use only privileged accounts when absolutely necessary ...

0
source

Source: https://habr.com/ru/post/926471/


All Articles