4

I have been trying to get PHP CLI (7.0.7 on Ubuntu) working together with mysqli, but without success. I keep getting the same error message when starting it:

mysqli.so: undefined symbol: mysqlnd_connect in Unknown on line 0

This is some of the output from php -i (clearly showing both were loaded):

mysqli

MysqlI Support => enabled
Client API library version => mysqlnd 5.0.12-dev - 20150407 - $Id: 241ae00989d1995ffcbbf63d579943635faf9972 $
Active Persistent Links => 0
Inactive Persistent Links => 0
Active Links => 0

Directive => Local Value => Master Value
mysqli.allow_local_infile => On => On
mysqli.allow_persistent => On => On
mysqli.default_host => no value => no value
mysqli.default_port => 3306 => 3306
mysqli.default_pw => no value => no value
mysqli.default_socket => no value => no value
mysqli.default_user => no value => no value
mysqli.max_links => Unlimited => Unlimited
mysqli.max_persistent => Unlimited => Unlimited
mysqli.reconnect => Off => Off
mysqli.rollback_on_cached_plink => Off => Off

mysqlnd

mysqlnd => enabled
Version => mysqlnd 5.0.12-dev - 20150407 - $Id: 241ae00989d1995ffcbbf63d579943635faf9972 $
Compression => supported
core SSL => supported
extended SSL => supported
Command buffer size => 4096
Read buffer size => 32768
Read timeout => 31536000
Collecting statistics => Yes
Collecting memory statistics => No
Tracing => n/a
Loaded plugins => mysqlnd,debug_trace,auth_plugin_mysql_native_password,auth_plugin_mysql_clear_password,auth_plugin_sha256_password
API Extensions => mysqli,pdo_mysql

PHP was installed using sudo apt install php7.0-cli.

What is wrong?

fgblomqvist
  • 151
  • 1
  • 1
  • 5

5 Answers5

4

When you load mysqli after mysqlnd, this solves the issue. BUT

if you use phpenmod to enable the modules they enable in alphabetical order. mysqli is before mysqlnd in the order.

I got around this by renaming the symlinks to mysqli to zmysqli - crude, but it worked.

1

I was going through multiple installation documents for php and one said to enable extension = mysqli in the php.ini (uncomment it) but phpenmod was enabled and so the mysqli shouldn't be in php.ini I commented out the line and everything loaded properly.

Joe
  • 11
  • 1
0

In my situation (Debian 9) the order was correct: the php-mysqlnd.ini file was at the top of the list of modules. To change the modules order just change the trailing number so you should have "10-mysqlnd.ini" and "20-mysqli.ini" links pointing to their .ini files in mods-available. What I've noticed was that the "mysqlnd.ini" file was empty, maybe for a wrong installation. I've simply added some content like "extension=mysqlnd.so" (the library file was correctly installed) and everything has worked!

Fabar
  • 1
0

Similar, if not the same issue:

PHP Warning:  PHP Startup: Unable to load dynamic library 'mysql' (tried: /usr/lib64/php/modules/mysql (/usr/lib64/php/modules/mysql: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/mysql.so (/usr/lib64/php/modules/mysql.so: undefined symbol: mysqlnd_get_client_info)) in Unknown on line 0

Which can be resolved by loading module mysql (the only difference) after module mysqlnd:

sudo mv /etc/php-cli.d/20-mysql.ini /etc/php-cli.d/21-mysql.ini
Martin Zeitler
  • 171
  • 1
  • 6
0

The reason because you need to load mysqlnd before you load the mysql/php-mysqli/mysqli/php-mysqli extension.

Check you php.ini whether php-mysqlnd has been loaded before you load those extensions. Sometimes, apache decided to separate all the extensions into separate .ini files, you have to make sure that the mysqlnd file is loaded before php-mysqli extension and friend by renaming the file.