1

I am upgrading a server from vulnerable mysql_* functions to better $mysqli-> functions, but I've run into a problem at the very beginning. I have something like this:

$host = "localhost";
$u = "user";
$p = "pass";
$db = "database";

The old connection protocol looks like this:

$link = mysql_connect($host, $u, $p);
if(!$link){die();}
mysql_select_db($db);

This works just fine. I can connect, authenticate, and access the database. However, this code:

$link = new mysqli($host, $u, $p, $db);
if(!$link){die();}

This results in an Access Denied for user xxxxx@localhost (using password: YES) error.

I have made used mysqli so many times, but I've never had this happen.

Additional things I've tried

  • Specifying port 3306 does not help
  • Specifying the WAN IP does not help
  • mysqli_connect
  • 127.0.0.1

Mysqli settings:

MysqlI Support => enabled
Client API library version => 5.1.54
Active Persistent Links => 0
Inactive Persistent Links => 0
Active Links => 0
Client API header version => 5.1.54
MYSQLI_SOCKET => /var/lib/mysql/mysql.sock

Directive => Local Value => Master Value
mysqli.allow_local_infile => On => On
mysqli.allow_persistent => On => On
mysqli.default_host => no value => no value
mysqli.default_port => 3306 => 3306
mysqli.default_pw => no value => no value
mysqli.default_socket => no value => no value
mysqli.default_user => no value => no value
mysqli.max_links => Unlimited => Unlimited
mysqli.max_persistent => Unlimited => Unlimited
mysqli.reconnect => Off => Off

Update

  • MYSQL_SOCKET = MYSQLI_SOCKET
  • Specifying the socket manually in the new mysqli does nothing
  • Adding extension=mysqli.so to the php.ini did nothing.
  • Restarting Apache after all of this did nothing.
David
  • 21,070
  • 7
  • 57
  • 113

0 Answers0