Linux

安裝支持 MySQL 的 PHP?

  • October 16, 2010

我已經從我的託管服務提供商處安裝了 PHp,但它似乎沒有內置 mysql 支持。我被重定向到安裝腳本:

/usr/bin/mysql_secure_installation

其中安裝了 mysql 作為程序,但 phpinfo() 仍然顯示:

配置命令 ‘./configure’ ‘–build=x86_64-redhat-linux-gnu’ ‘–host=x86_64-redhat-linux-gnu’ …. …… ‘–沒有-mysql’ '

接下來我該怎麼做才能獲得 mysql 支持?

安裝 php-mysql:

yum install php-mysql

然後檢查 /etc/php.d/mysql.ini 文件。測試 php:

php -i | grep -i mysql
/etc/php.d/mysql.ini,
/etc/php.d/mysqli.ini,
/etc/php.d/pdo_mysql.ini,
MySQL Support => enabled
MYSQL_MODULE_TYPE => external
MYSQL_SOCKET => /var/lib/mysql/mysql.sock
MYSQL_INCLUDE => -I/usr/include/mysql
MYSQL_LIBS => -L/usr/lib/mysql -lmysqlclient 

php -r 'mysql_connect();'
PHP Warning:  mysql_connect(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in Command line code on line 1

引用自:https://serverfault.com/questions/191609