Unable to connect to MySQL from PHP: "mysql_connect (): no such file or directory"

I cannot connect to mysql via php. It creates an error message [error] [client 127.0.0.1] PHP Warning: mysql_connect(): No such file or directoryin the apache error log when executing a function mysql_connect()in PHP.

When running the command, php -mfind the warning messages:

$ 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 spent a lot of time trying to fix this. Please suggest! Thank!

+3
source share
2 answers

Your problem may be related to "remote access". You should try changing the mysql configuration. The file can be called my.cnf.

, : http://www.debianhelp.co.uk/remotemysql.htm

+1

Mac OS X Lion, / IP-.
: localhost 127.0.0.1 PHP-.

+7

Source: https://habr.com/ru/post/1764867/


All Articles