微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐