php / php-src

The PHP Interpreter
https://www.php.net
Other
37.69k stars 7.71k forks source link

Failed to make extensions `mysqli` #14908

Closed WenisOK closed 1 week ago

WenisOK commented 2 weeks ago

Description

when I executed make test,the console threw a series of the same errors. such as Fatal error: Uncaught Error: Class "mysqli_driver" not found in /root/php-8.3.9/ext/mysqli/tests/connect.inc:9 see more please read attached file. php_test_results_20240710_2111.txt

The following code:

<?php

$conn = mysqli_connect("localhost","user", "password");

if ($conn) {
    echo "Connect successful";
} else {
    echo "Connect failed";
}

Resulted in this output:

PHP Warning:  Packets out of order. Expected 3 received 2. Packet size=22 in /work/nginx/html/blog/test.php on line 3
PHP Fatal error:  Uncaught mysqli_sql_exception: MySQL server has gone away in /work/nginx/html/blog/test.php:3
Stack trace:
#0 /work/nginx/html/blog/test.php(3): mysqli_connect()
#1 {main}
  thrown in /work/nginx/html/blog/test.php on line 3

PHP Version

PHP 8.3.9

Operating System

Debian 12.5

SakiTakamachi commented 2 weeks ago

Sorry, I commented in the wrong thread.

SakiTakamachi commented 2 weeks ago

Will this test code always result in an error? Also, could you tell me the version of MySQL?

WenisOK commented 2 weeks ago

Will this test code always result in an error? Also, could you tell me the version of MySQL?

yeah, my mysql version is 8.4 lts

WenisOK commented 2 weeks ago

This extension is compiled using the following commands in the ext/mysqli folder under the source code

phpize
./configure --with-php-config=/path/to/bin/php-config
make
make install

When executing make test, it reported any error, even though I enabled the following settings in php. ini

...
extension=mysqlnd
extension=mysqli
...

I have already installed the following packages in advance

libxml2-dev libsqlite3-dev pkg-config build-essential libpcre2-dev zlib1g-dev libmysqlclient-dev
SakiTakamachi commented 1 week ago

Sorry for the late reply. If the extension is not loaded, you can check that it is not enabled in phpinfo. What state is mysqli in in phpinfo?

WenisOK commented 1 week ago

Hi, thank you for waiting. Here is the output of the command php -m:

PHP Warning:  PHP Startup: Unable to load dynamic library 'mysqlnd' (tried: /work/php8/lib/php/extensions/no-debug-non-zts-20230831/mysqlnd (/work/php8/lib/php/extensions/no-debug-non-zts-20230831/mysqlnd: cannot open shared object file: No such file or directory), /work/php8/lib/php/extensions/no-debug-non-zts-20230831/mysqlnd.so (/work/php8/lib/php/extensions/no-debug-non-zts-20230831/mysqlnd.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'mysqli' (tried: /work/php8/lib/php/extensions/no-debug-non-zts-20230831/mysqli (/work/php8/lib/php/extensions/no-debug-non-zts-20230831/mysqli: cannot open shared object file: No such file or directory), /work/php8/lib/php/extensions/no-debug-non-zts-20230831/mysqli.so (/work/php8/lib/php/extensions/no-debug-non-zts-20230831/mysqli.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
[PHP Modules]
Core
ctype
curl
date
dom
exif
fileinfo
filter
gd
hash
iconv
imagick
intl
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcre
PDO
pdo_sqlite
Phar
posix
random
Reflection
session
SimpleXML
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
zip
zlib

[Zend Modules]

This is how I wrote it in the PHP file 'php info. php'

<?php
    phpinfo();
?>

This is the output of 'phpinfo', it doesn't look like there are any errors, just a warning prompt? 微信截图_20240717190917

WenisOK commented 1 week ago

Oh, I'm sorry, I forgot to tell you that after being unable to connect to the database, I recompiled PHP using the following compilation parameters./configure --prefix=/path/to/php8 --enable-fpm --with-mysqli=mysqlnd, After successful compilation, the database can connect normally, but this warning appears.

SakiTakamachi commented 1 week ago

Thanks, that warning should go away if you remove or comment out the following:

extension=mysqlnd
extension=mysqli
WenisOK commented 1 week ago

Thanks, that warning should go away if you remove or comment out the following:

extension=mysqlnd
extension=mysqli

Yes, it is already enabled in PHP.ini