In PHP, the Mysql_connect module has been gradually deprecated, I did not install the MySQL extension when setting up the environment, but today in the maintenance of an old project, an error occurred
Fatal error:uncaught error:call to undefined function mysql_connect ()
So Google, found that if both PHP and MySQL have been installed, you can use the Phpize tool to manually compile the build mysql.so extension to solve
Here are the steps to proceed:
1. Enter the PHP source Ext/mysql directory
cd/usr/local/src/php-5.6.29/ext/mysql/
2. Run phpize to generate a configure file in this directory (PHP installation directory:/usr/local/php/)
/usr/local/php/bin/phpize
3. Run configure, indicating the Php-config file location (/usr/local/php/bin/php-config) and the MySQL installation directory (/usr/local/mysql/)
./configure--with-php-config=/usr/local/php/bin/php-config--with-mysql=/usr/local/mysql/
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
<?php$con = mysql_connect (' localhost ', ' root ', '), if ($con) {die (' OK ');} else{die (' Could not connect: '. Mysql_error ());}
Access URLs, such as: http://192.168.8.9/mysql.php
Show OK, the configuration is successful
See MORE:
MySQL optimization
MySQL each storage engine
MySQL Lock explanation
MySQL Transaction
MySQL index type
PHP Installation mysql.so Extensions