PHP5.5连接mysql5.0报错

ZF报错

Zend_Db_Adapter_Exception:报错 "Zend_Db_Adapter_Exception: SQLSTATE[HY000] [2002] No such file or directory"



If you are running some Linux-based system, there should be a my.cnf file somewhere, that is used to configure MySQL -- on my Ubuntu, it's in /etc/mysql/.

In this file, there might be something like this :

socket = /var/run/mysqld/mysqld.sock

PHP need to use the same file -- and, depending on your distribution, the default file might not be the same as the one that MySQL uses.
In this case, adding these lines to your php.ini file might help :
mysql.default_socket = socket=/var/lib/mysql/mysql.sock
mysqli.default_socket =/var/lib/mysql/mysql.sock
pdo_mysql.default_socket = /var/lib/mysql/mysql.sock

Mysql有两种连接方式:
(1)TCP/IP
(2)socket
对mysql.sock来说,其作用是 程序与mysqlserver处于同一台机器,发起本地连接时可用
例如你无须定义连接host的具体IP得,只要为空或localhost就可以。
在此种情况下,即使你改变mysql的外部port也是一样可能正常连接。
因为你在my.ini中或my.cnf中改变端口后,mysql.sock是随每一次 mysql server启动生成的。已经根据你在更改完my.cnf后重启mysql时重新生成了一次,信息已跟着变更。


新版php连接旧版mysql时报错
update user set password=PASSWORD('archermind') where user='root';
flush privileges;

update user set password=PASSWORD('new password') where user='thisuser';

flush privileges;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值