macos – 无法从PHP连接到MySQL:“mysql_connect():没有这样的文件或目录”

我无法通过PHP连接到mysql.它生成[error] [client 127.0.0.1] PHP警告:MysqL_connect():在PHP中执行MysqL_connect()函数时,在apache错误日志中没有此类文件或目录错误消息.

运行PHP -m命令时请查看警告消息:

$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

$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版本:

$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版本:

MysqL --version
/usr/local/MysqL/bin/MysqL  Ver 14.14 distrib 5.1.50, for apple-darwin10.3.0 (i386) using readline 5.1

我花了很多时间来解决这个问题.请指教!谢谢!

解决方法:

您的问题可能与“远程访问”有关.你应该尝试编辑MysqL的配置.该文件可能被称为my.cnf.

这是一个可能有用的链接
http://www.debianhelp.co.uk/remotemysql.htm

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...