Home  >  Article  >  Backend Development  >  linux下php连接mysql异常

linux下php连接mysql异常

WBOY
WBOYOriginal
2016-06-13 11:09:501029browse

linux上php连接mysql错误
我的php版本是5.2.13,ysql版本是5.0,在执行下面的语句时
$con = mysql_connect($host_port,$user,$passwd);
报了错误:
PHP Fatal error:  Call to undefined function mysql_connect()

我查看了下phpinfo()里的信息,有如下两个选项:'--with-mysql=shared,/usr' '--with-mysqli=shared,/usr/bin/mysql_config' 
另外,在我的/etc/php.ini中查看extension_dir = "/usr/lib64/php/modules",在/usr/lib64/php/modules 这个目录下,却发现没有mysql.so文件。
我尝试了下:

/usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/auto/DBD/mysql/mysql.so
下的mysql.so拷贝到 /usr/lib64/php/modules下,再执行一次
$con = mysql_connect($host_port,$user,$passwd);
仍然报: Call to undefined function mysql_connect()

请问我是不是还要装某些包啊?比如php-mysql和papache2-mod_php这两个包
------解决方案--------------------
mysql启动了吗?service mysql start 或者 service mysqld start 
或者查看一下而 error log 

------解决方案--------------------
你看一下你执行php的用户对于mysql.so的权限

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn