如下所示,PHP连接MySQL报错: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket 'MySQL' (2) 测试代码如下: <?php try { $dsn = 'mysql:dbname=php-note;host=localhost;port=3306;charset=utf8'; $username = 'root'; $password = 'root'; new PDO( $dsn,…
SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)   这个 问题产生是因为修改my.cnf,重启服务造成的,一般没有影响.可以不用处理.…
我的环境:Mac 10.11.6 ,mysql  5.7.14  . mac mySql 报错ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) 这个错是链接时报的错,要链接必须启动.修复的时候首先要启动mysql. 首先来了解一下 mysql.sock的作用: Mysql有两种连接方式: (1),TCP/IP (2),socket 对mysql.sock来说,其…
一早上过来发现网站打开报错,数据库连接不上.. 有人改密码? putty进去,mysql -uroot -p 输入密码后,报错 ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' 不是密码问题,百度主要有几个可能原因 1.my.cnf 配置问题,里面会设置 socket  /tmp/mysql.sock, 有说配置文件不存在,新建的 2.文件sock权限不够的 发现文件存…
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) 背景: mysql -uroot -p123456 提示: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) 原因: mysql.sock文件是服务器与本地客户端进行通信的Uni…
好久不用mysql,今天突然想用的时候, mysql -uroot -p 直接报了下面的错误 ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) mac可以在设置里面启动mysql,设置里面启动mysql的时候提示没有/usr/local/mysql/data的权限, 给予权限 sudo chown -R mysql:mysql  /usr/local/mysql…
首先安装 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,之前没有使用过,今天启动的时候发现启动不了 huijundeMacBook-Pro:bin huijunzhang$ mysql ERROR (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) 查看mysql的安装位置: huijundeMacBook-Pro:bin huijunzhang$ which mysql /usr/local/bin/…
[root@XXX ~]# mysql -h localhost -uroot -p Enter password: ERROR (HY000): Can't connect to local MySQL server through socket '/tmp/mysql/mysql.sock' (2) [root@XXX ~]# mysql -uroot -pEnter password:ERROR 2002 (HY000): Can't connect to local MySQL serv…
输入 mysql -u root 登录 mysql 的时候出现以下错误: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) 解决方法: touch /var/lib/mysql/mysql.sock      (如果目录里没有这个文件就手动创建) mysql.sock的路径可以查看/etc/my.cnf文件 chmod 777 /var/lib/mysql/my…