我在centos 6.5系统中使用php-mysql-apache所有要求都存在,我想我可以在localhost中发布我的html文件但是当我尝试在php脚本中连接到mysql时。它没有出现,它显示 mysql 连接错误。
# rpm -qa |grep php
php-pdo-5.3.3-26.el6.x86_64
php-common-5.3.3-26.el6.x86_64
php-5.3.3-26.el6.x86_64
php-mysql-5.3.3-26.el6.x86_64
php-cli-5.3.3-26.el6.x86_64
php-ldap-5.3.3-26.el6.x86_64
# rpm -qa |grep mysql
mysql-libs-5.1.71-1.el6.x86_64
mysql-community-release-el6-5.noarch
mysql-5.1.71-1.el6.x86_64
mysql-server-5.1.71-1.el6.x86_64
php-mysql-5.3.3-26.el6.x86_64
我还检查了我的 mysql 密码和用户名是否正确,我尝试如下连接:
$connect= mysql_connect("localhost","root","password");
if(!$connect){
echo "Failed to connect to MySQL " ;
}
php.ini 文件的“动态扩展”部分如下:
;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;
; If you wish to have an extension loaded automatically, use the following
; syntax:
;
; extension=modulename.extension
;
; For example
;
; extension=msql.so
;
; ... or with a path:
;
; extension=/path/to/extension/msql.so
;
; If you only provide the name of the extension, PHP will look for it in its
; default extension directory.
extension=mysql.so
extension=mysqli.so
;;;
; Note: packaged extension modules are now loaded via the .ini files
; found in the directory /etc/php.d; these are loaded by default.
;;;;
我手动添加了这些行;
extension=mysql.so
extension=mysqli.so
那么我的错在哪里,你知道在 localhost 中运行我的 php 脚本吗?