我已经从托管服务提供商处安装了 PHp,但它似乎没有内置 mysql 支持。我被重定向到安装脚本:
/usr/bin/mysql_secure_installation
将 mysql 安装为程序,但 phpinfo() 仍然显示:
配置命令'./configure''--build=x86_64-redhat-linux-gnu''--host=x86_64-redhat-linux-gnu'..............................'--without-mysql''
我下一步该做什么才能获得 mysql 支持?
答案1
安装 php-mysql:
yum install php-mysql
然后检查 /etc/php.d/mysql.ini 文件。Tets 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