Knowledge base

Lion Server: Configuring PHP for MySQL

Posted in Apple Portable Computers

Products Affected

Lion Server, MySQL, PHP

You must explicitly define the following values in /etc/php.ini.

The default TCP port for MySQL is traditionally 3306, so mysql.default_port, mysqli.default_port and pdo_mysql.default_port should all be defined with this value.

The traditional MySQL socket on previous Mac OS X Server versions was /var/mysql/mysql.sock, which is appropriate for systems that continue to use the Apple-provided 5.0 installation migrated from Mac OS X Server v10.5 or v10.6. If you have installed MySQL from mysql.com, the default socket is /tmp/mysql.sock. The directives mysql.default_socket, mysqli.default_socket and pdo_mysql.default_socket should all be defined with the path that matches your installation.

The versions of PHP delivered with Mac OS X Server v10.6 and Lion Server can also communicate to a remote MySQL server without MySQL or any of its libraries being installed on the local computer. To do so, define mysql.default_host, mysqli.default_host or pdo_mysql.default_host to the default remote host.

Additional Information

For more information about available MySQL directives, see:


Note that PHP and MySQL recommend the use of PHP's mysqli APIs instead of PHP's mysql APIs to take advantage of MySQL's latest features: http://us3.php.net/manual/en/mysqli.overview.php.

Important: Mention of third-party websites and products is for informational purposes only and constitutes neither an endorsement nor a recommendation. Apple assumes no responsibility with regard to the selection, performance or use of information or products found at third-party websites. Apple provides this only as a convenience to our users. Apple has not tested the information found on these sites and makes no representations regarding its accuracy or reliability. There are risks inherent in the use of any information or products found on the Internet, and Apple assumes no responsibility in this regard. Please understand that a third-party site is independent from Apple and that Apple has no control over the content on that website. Please contact the vendor for additional information.

One Moment Please

Thanks for rating this article

Read more http://support.apple.com/kb/HT4844