I did not install the MySQL extension when I was setting up the environment, but I got an error while maintaining a project today.
Fatal error:uncaught error:call to undefined function mysql_connect ()
You can use the Phpize tool to manually compile the build mysql.so extension to resolve
Here are the steps to proceed:
1. Enter the PHP source Ext/mysql directory
cd/home/oldboy/tools/php-5.5.32/ext/mysql/
2. Run phpize to generate a configure file in this directory (PHP installation directory:/application/php/)
/application/php/bin/phpize
3. Run configure to indicate the Php-config file location (/application/php/bin/php-config) and MySQL installation directory
./configure--with-php-config=/application/php/bin/php-config--with-pdo-mysql=mysqlnd
4. Compile and install, generate mysql.so
Make && make install
5. Modify the php.ini file, add mysql.so extension configuration, save exit
Extension=mysql.so
6. Restart PHP-FPM
Service PHP-FPM Restart
7. Test, add php files to the web directory, such as/usr/local/nginx/html/mysql.php
Copy Code
<?php
$con = mysql_connect (' localhost ', ' root ', ');
if ($con) {
Die (' OK ');
}else{
Die (' Could not connect: '. Mysql_error ());
}
This article is from "Poetry and Distance" blog, please be sure to keep this source http://dreammoon.blog.51cto.com/12317841/1919907
PHP connection MySQL mysql_connect () function is not available, reported 500 error