[blfs-dev] mysql and php

Bruce Dubbs bruce.dubbs at gmail.com
Tue Feb 5 15:44:07 PST 2013

I was looking at some php code and noticed that the mysql interface has 
been marked deprecated in favor of the mysqli interface.  In 
experimenting, I couldn't get php to connect to mysql.

My php build includes '--with-mysqli' '--with-pdo-mysql=mysqlnd'

I was using the command:

   $mysqli = new mysqli("localhost", "", "", "test" );

After some research, I found the following did work:

   $mysqli = new mysqli("", "", "", "test");

However, I'd prefer to use UNIX sockets to a TCP connection.  With a 
little more research, I found that the /etc/php.ini needed to specify 
the mysql socket:

mysqli.default_socket = /run/mysql/mysql.sock

I think this can be set automatically if specified in the php configure 
command:  --with-mysql-sock=/run/mysql/mysql.sock

But I have not tested that.

I notice that mysql_version.h defines MYSQL_UNIX_ADDR as 
"/var/run/mysql/mysql.sock" and that exists because /var/run is a 
symlink to /run, but it doesn't seem to be picked up by php, at least as 
far as mysqli is concerned.

   -- Bruce

More information about the blfs-dev mailing list