Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to load dynamic library 'mysqli' #14051

Closed
logan-oss opened this issue Apr 26, 2024 · 8 comments
Closed

Unable to load dynamic library 'mysqli' #14051

logan-oss opened this issue Apr 26, 2024 · 8 comments

Comments

@logan-oss
Copy link

Hello,
I have a issue with php in MacOS. I use a MacBook Air M1 2020 and i have a issue with php extensions. I can't use mysqli extension because the file mysqli.so doesn't exist.
The complete message is :
PHP Warning: PHP Startup: Unable to load dynamic library 'mysqli' (tried: /opt/homebrew/lib/php/pecl/20230831/mysqli (dlopen(/opt/homebrew/lib/php/pecl/20230831/mysqli, 0x0009): tried: '/opt/homebrew/lib/php/pecl/20230831/mysqli' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/lib/php/pecl/20230831/mysqli' (no such file), '/opt/homebrew/lib/php/pecl/20230831/mysqli' (no such file)), /opt/homebrew/lib/php/pecl/20230831/mysqli.so (dlopen(/opt/homebrew/lib/php/pecl/20230831/mysqli.so, 0x0009): tried: '/opt/homebrew/lib/php/pecl/20230831/mysqli.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/lib/php/pecl/20230831/mysqli.so' (no such file), '/opt/homebrew/lib/php/pecl/20230831/mysqli.so' (no such file))) in Unknown on line 0

@devnexen devnexen transferred this issue from php/doc-fr Apr 26, 2024
@devnexen
Copy link
Member

If you re using the homebrew php formula, mysqli is not a shared dynamic module but a builtin one. Did you modify module loading configuration in php.ini or anything ?

@logan-oss
Copy link
Author

@devnexen Thanks for your reactivity. I just install php with homebrew and uncomment the 'extension=mysqli' to use it. But i always get a error when i try to execute the code.

@devnexen
Copy link
Member

why do you need to uncomment this line to use mysqli ?

@petk
Copy link
Member

petk commented Apr 28, 2024

When using Homebrew, mysqli is built into php package itself: https://github.com/Homebrew/homebrew-core/blob/093893a86a134347ee515d53f977ea2f0a1cc808/Formula/p/php.rb#L167

Similar issue: shivammathur/homebrew-php#73

Probably commenting back that extension=mysqli extension will be enough.

@logan-oss
Copy link
Author

For me it's not enought because i get a error message that say that mysqli extension is missing.
ERROR LOGS:
Fatal error: Uncaught mysqli_sql_exception: No such file or directory

@devnexen
Copy link
Member

Is your mysqli code within a try/catch block ?

@DeveloperRob
Copy link

@logan-oss: If you are getting a mysqli_sql_exception}, at that point the extension itself is loaded correctly (as the extension provides that exception class).

Although the error message might not be obvious, it can mean that your code is trying to connect to the database server via a UNIX socket (as opposed to via an IP address) and that socket file isn't found (i.e. there isn't a local database server running). I would suggest double checking the database server you are trying to connect to (can you connect to it via a GUI for instance); and once you have confirmed it is running correctly, double check your code to ensure your code is connecting to it correctly.

@nielsdos
Copy link
Member

Fatal error: Uncaught mysqli_sql_exception: No such file or directory

This doesn't mean the extension can't be found, it means that it can't connect to the mysqli socket, i.e. the "no such file or directory" is about the socket.
Anyway, this doesn't seem like a bug in PHP but a bug in the code as pointed out earlier.

@nielsdos nielsdos closed this as not planned Won't fix, can't repro, duplicate, stale May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants