I'm not able connect to mysql via php. It produces [error] [client 127.0.0.1] PHP Warning: mysql_connect(): No such file or directory
error message in apache error log when executing mysql_connect()
function in PHP.
Please find the warning messages when running php -m
command:
$ php -m | grep mysql
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20090626/msql.so' - dlopen(/usr/lib/php/extensions/no-debug-non-zts-20090626/msql.so, 9): image not found in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20090626/php_mysql.dll' - dlopen(/usr/lib/php/extensions/no-debug-non-zts-20090626/php_mysql.dll, 9): image not found in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20090626/php_mysqli.dll' - dlopen(/usr/lib/php/extensions/no-debug-non-zts-20090626/php_mysqli.dll, 9): image not found in Unknown on line 0
mysql
mysqli
mysqlnd
pdo_mysql
and
$ mysqladmin -h `hostname` --port=3306 version
/usr/local/mysql/bin/mysqladmin: connect to server at 'heapzero.local' failederror: 'Host '192.168.1.36' is not allowed to connect to this MySQL server'
PHP Version:
$ php --version
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20090626/msql.so' - dlopen(/usr/lib/php/extensions/no-debug-non-zts-20090626/msql.so, 9): image not found in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20090626/php_mysql.dll' - dlopen(/usr/lib/php/extensions/no-debug-non-zts-20090626/php_mysql.dll, 9): image not found in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20090626/php_mysqli.dll' - dlopen(/usr/lib/php/extensions/no-debug-non-zts-20090626/php_mysqli.dll, 9): image not found in Unknown on line 0
PHP 5.3.2 (cli) (built: Aug 7 2010 00:04:41)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
MySQL Version:
mysql --version
/usr/local/mysql/bin/mysql Ver 14.14 Distrib 5.1.50, for apple-darwin10.3.0 (i386) using readline 5.1
I've spent lot of time in trying to fix this. Please suggest! Thanks!
If you use Mac OS X Lion, try changing the server/host name to IP address instead.
Example: instead of localhost
, use 127.0.0.1
in the PHP code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With