can't connect local MySql Server though socket "/tmp"如何解决

openwrt上安装php,提示如此

网上一大通找

发现的都是can‘t connect local MySql Server though socket "/tmp/mysql.socket"如何解决

人家还是找的mysql.socket;我的竟然直接找的tmp目录,真是无语。人家的解决方法使用软连接直接无效;

难道要我自己编译php吗?想想都头大。

继续找方案:

在此文档中

http://kong1616.iteye.com/blog/682342

发现了这么一句话

在/etc/php.ini修改mysql.default_socket的值,在这个文件中,关于mysql.default_socket的值的说明是这样的, 
; Default socket name for local MySQL connects.  If empty, uses the built-in MySQL defaults. 
这个值一开始是空的,也就是说,如果我们不主动去修改的话,php将会使用内建在mysql中的默认值 

真是救命稻草,我的php程序用的mysqli,而php.ini中配置的都是mysql,所以,php.ini加上如下内容,顺利解决问题:

[MYSQLI]
mysqli.allow_local_infile = On
mysqli.allow_persistent = On
mysqli.cache_size = 2000
mysqli.max_persistent = -1
mysqli.max_links = -1
mysqli.default_port =3306
mysqli.default_socket =/tmp/mysql.sock
mysqli.default_host =127.0.0.1
mysqli.default_user =root
mysqli.default_password =19870215
mysqli.connect_timeout = 60
mysqli.trace_mode = Off

can't connect local MySql Server though socket "/tmp"如何解决

时间: 2024-10-19 23:54:51

can't connect local MySql Server though socket "/tmp"如何解决的相关文章

MAC中Django中runserver提示Can't connect to local MySQL server through socket '/tmp/mysql.sock错误

好像不止遇到一次,直接Google就可以了,在stackoverflow中就有答案,答案就是你没有开MySQL - -. stackoverflow链接见 http://stackoverflow.com/questions/16325607/cant-connect-to-local-mysql-server-through-socket-tmp-mysql-sock 开启MySQL的命令如下: mysql.server start MAC中Django中runserver提示Can't co

Can't connect to local MySQL server through socket '/tmp/mysql.sock'

启动mysql之后,不能进入mysql命令行: Can't connect to local MySQL server through socket '/tmp/mysql.sock': 修改/etc/my.cnf 当中 socket=/tmp/mysql.sock 重启mysql,即可 Can't connect to local MySQL server through socket '/tmp/mysql.sock'

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

我在源码编译安装mysql后,虽然mysql服务可以正常启动,但是当我直接执行mysql后,出现了错误. 错误提示如下: [[email protected] ~]# mysql ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) 出现错误原因: 由于mysql 默认的mysql.sock 是在/var/lib/mysql/mysql.sock,但linux系统总

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock'

原因:找不到mysql.sock文件 解决方法: 1 找到mysql.sock文件位置 echo "show variables" | mysql | grep "socket"或者echo "status" | mysql | grep "socket" 2 ln -s /var/lib/mysql /mysql .sock /tmp/mysql .sock 将两个文件做一个软连接 ERROR 2002 (HY000): C

Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

这个实在linux下安装mysql的情况,出现了Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) 这个错误,然后service mysql start 一直启动不了. 那么可以用一下的方法 #ps -A|grep mysql 显示类似: 3016 ?        00:00:00 mysqld_safe 3090 ?        00:00:31 mysqld 2.#kill -9 3016 3.

长久不用的mysql报错ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

mac上安装过mysql: 然而,尝试连接时报错: $ mysql -u root -p Enter password: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) 尝试去查看mysql.socket文件,发现没有.. $ which mysql /usr/local/bin/mysql 然后试试重启mysql: $ mysql.server start

error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'

1.今天安装了一个mysql 5.7 的二进制安装方式,在连接mysql数据库的时候报了如下错误: [[email protected] mysql]# mysql ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) 2.根据提示应该是sock文件不在,通过查看进程配置,发现如下 [[email protected] bin]# ps -ef | grep mys

mac 安装mysql 报错“ERROR 2002 (HY000): Can not connect to local MySQL server through socket '/tmp/mysql.sock' (2)” 解决办法

首先安装 homebrew 再 brew install mysql 之后连接 mysql 无论是登录还是修改初始密码都会报如下的错误 ERROR 2002 (HY000): Can not connect to local MySQL server through socket '/tmp/mysql.sock' (2) 运行如下解决:参考 http://www.thinksaas.cn/group/topic/347978/ unset TMPDIR mysql_install_db --v

mac使用brew安装mysql报RROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

使用mac安装mysql安装完后运行 mysql -uroot -p 报了 ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) 这是由于我们没有启动mysql,启动mysql使用 brew services start mysql或者 mysql.server start 在启动前我们可以设置一下root密码 mysql_secure_installation 然