Php 无法在centos 6.5中连接mysql

Php 无法在centos 6.5中连接mysql,php,mysql,mysqli,mysql-connect,centos6.5,Php,Mysql,Mysqli,Mysql Connect,Centos6.5,我在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

我在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 " ;
}
;;;;;;;;;;;;;;;;;;;;;;
; 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.
;;;;
php.ini文件的“动态扩展名”部分如下:

$connect= mysql_connect("localhost","root","password");
if(!$connect){
    echo "Failed to connect to MySQL " ;
}
;;;;;;;;;;;;;;;;;;;;;;
; 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

那么我的错在哪里呢?你有没有办法在本地主机上运行我的php脚本?

不要使用
mysql\u connect
,因为它已被弃用,请使用MySQLi或PDO进行连接–这确实很痛苦,但请检查Apache错误日志或启用php以显示脚本中的所有错误,这可能会有所帮助