A:
Use the phpinfo() function in your PHP code to see PHP basics
Mysql_connect () has been deprecated since PHP5.0, and is deprecated in PHP7.0. Mysqli_connect () is used instead if PHP is 7.0 or higher
Method 2:
Missing MySQL module caused by PHP installation
Mysql> install mysql from CentOs
yum install php-mysql -y
If installed, report the following warning
Headers and client library minor version mismatch. Headers:
This is due to the higher version of MySQL, the lower version of the MySQL Client API
You can uninstall php-mysql first
yum remove php-mysql -y
then
yum install php-mysqlnd -y
Finally, restart Apache
systemctl restart httpd
Ubuntu install MySQL module:
Apt to get the install php5 – mysql
Sudo DPKG — reconfigure php5 – mysql
sudo /etc/init.d/mysql restart
sudo /etc/init.d/apache2 restart
Three:
If the first two methods fail, try opening the MySQL module extension in the php.ini configuration file
Php.ini = php.ini; Extension =” related MySQL module “; To get rid of
Then make sure that the dir of extension points to the directory where the extension resides
Windows is usually under Ext and CentOS is under /usr/lib64/php.modules
The above information can be found in the PHPINFO printed information
However, when I encountered this problem, I just needed to install the PHP-MySQL module, and I didn’t need to modify php.ini
My environment is Centos7 and PHP version is PHP5.4
Use the phpinfo() function in your PHP code to see PHP basics
Mysql_connect () has been deprecated since PHP5.0, and is deprecated in PHP7.0. Mysqli_connect () is used instead if PHP is 7.0 or higher
Method 2:
Missing MySQL module caused by PHP installation
Mysql> install mysql from CentOs
yum install php-mysql -y
If installed, report the following warning
Headers and client library minor version mismatch. Headers:
This is due to the higher version of MySQL, the lower version of the MySQL Client API
You can uninstall php-mysql first
yum remove php-mysql -y
then
yum install php-mysqlnd -y
Finally, restart Apache
systemctl restart httpd
Ubuntu install MySQL module:
Apt to get the install php5 – mysql
Sudo DPKG — reconfigure php5 – mysql
sudo /etc/init.d/mysql restart
sudo /etc/init.d/apache2 restart
Three:
If the first two methods fail, try opening the MySQL module extension in the php.ini configuration file
Php.ini = php.ini; Extension =” related MySQL module “; To get rid of
Then make sure that the dir of extension points to the directory where the extension resides
Windows is usually under Ext and CentOS is under /usr/lib64/php.modules
The above information can be found in the PHPINFO printed information
However, when I encountered this problem, I just needed to install the PHP-MySQL module, and I didn’t need to modify php.ini
My environment is Centos7 and PHP version is PHP5.4
Read More:
- PHP connection to MySQL database error: call to undefined function MySQL_ connect()
- Fatal error: Uncaught Error: Call to undefined function mysql_connect()
- Fatal error: Uncaught Error: Call to undefined function mysql_ Connect() problem solving
- Uncaught error: call to undefined function MySQL when building sqli lab environment with phpstudy_ Connect() error
- Call to undefined function oci_ Connect() problem solving
- PHP connection PostgreSQL error call to undefined function PG_ connect()
- Uncaught Error: Call to undefined function mysql_select_db()
- PHP error: call to undefined function curl_ init() window
- bug-JAVA call SAP function Connect to SAP gateway failed
- Sqlog connect to MySQL 8.0.24 remote server, error: 2058 solution
- MySQL: if the remote connection using navicatip fails, prompt “is not allowed to connect to this MySQL server”
- It can’t connect to local MySQL server through socket ‘/ tmp/ mysql.sock ‘(2) “;
- The MySQL service suddenly hangs up with the error message can’t connect to MySQL server on ‘localhost’ (10061)
- Navicat for MySQL error 1251 failed to connect to MySQL
- MySQL Workbench Failed to Connect to MySQL at 127.0.0.1:3306 with user root Bad handshake
- After installing MySQL again under Linux, the solution of ‘MySQL module failed to start’ appears
- C ා connect mysql: fatal error encountered during command execution solution
- Summary of MySQL error code
- Sqlog can’t connect to MySQL (1045 error)
- Can’t connect to MySQL server on ‘192.168.64.132‘