working with mysqli ini_set

2019-07-31 14:02发布

问题:

I've taken over a set up created by another developer and am unfamiliar with this line of set up. Could someone clarify this line of code?

ini_set ( 'mysqli.default_socket' , '/tmp/mysql5.sock' );

回答1:

ini_set() changes a runtime configuration value, to override the value that is in /etc/php.ini.

The mysqli options control usage of the MySQL database with the mysqli extension.

default_socket is one of the runtime configuration options for the mysqli extension.

The meaning of default_socket is the pathname of a "socket file" which is used for local access between the PHP application and the MySQL Server. That is, the socket is used only if your PHP application uses "localhost" as the hostname when connecting to MySQL. For more information, read http://dev.mysql.com/doc/refman/5.6/en/connecting.html

It would be necessary to specify a value for default_socket if the value in /etc/php.ini doesn't match the location of the socket file created by the instance of MySQL on this server.



标签: php mysqli