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 --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp

这时候可以通过 http://blog.sina.com.cn/s/blog_9ea3a4b70101ihl3.html  进行登录密码修改等等。

然后cd bin用
$ sudo ./mysql_secure_installation 
来修改root密码,默认为空,显然不太安全,然后根据提示酌情配置,因为是开发环境不用那么严格限制。
$ sudo ./mysqld_safe 
来启动mysql
$ sudo ./mysql -u root -p 
输入刚才设置的root密码来登录mysql
$ sudo ./mysqld_safe stop 
停止mysql

  

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

时间: 2024-12-05 13:56:31

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

Mac brew 安装mysql 报错 ERROR 2002 (HY000): Can't connect to local MySQL server through socket

安装mysql 最新版 56 brew install mysql 启动报错 ben:~ soul$ which mysql /usr/local/bin/mysql ben:~ soul$ mysql ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) 解决办法 运行 ben:~ soul$ mysql.server start Starting MySQL .

长久不用的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

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

[[email protected] mysql3307]# /opt/mysql3307/bin/mysql -upisp [email protected]123 mysql: [Warning] Using a password on the command line interface can be insecure. ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.so

mysql连接报错 ERROR 2002 (HY000): Can't connect to local MySQL server through socket

安装完mysql连接报错: [[email protected] app]# mysql ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) [[email protected] app]# mysql -uroot -p Enter password:  ERROR 2002 (HY000): Can't connect to local M

mysql报错ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)

23:29:02/2017-05-03 现象描述:在Command Line Client可以登陆,但是在命令提示符cmd下登陆出错. 我最终的解决办法是: 我先去看了一下我的my.ini配置文件. 新版5.7的配置文件不是在安装目录,而是在programDat/mysql文件目录下 打开文件之后: 我在安装的时候修改了默认端口3306为8082, 在cmd登陆的时候仍然是默认端口登陆的,所以会报错.那么在登陆的 时候可以指定端口, -P一定要大写. mysql报错ERROR 2003 (HY0

Mac下Mysql启动异常["ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)"]

在mac下使用brew安装mysql,之前没有使用过,今天启动的时候发现启动不了 huijundeMacBook-Pro:bin huijunzhang$ mysql ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) 查看mysql的安装位置: huijundeMacBook-Pro:bin huijunzhang$ which mysql /usr/local

mariadb报:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111 "Connection refused")

我这边移除了mysql.sock文件后,重启服务就成功了. 还有一种情况,就是加入galera后,可能是server.cnf配置信息出了问题导致的,修改后,重新运行galera即可,数据库就可以启动成功了. mariadb报:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111 "Connection refused") 原文地址:h

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

自己电脑远程连接后,centos服务器mysql连接 不上.报错: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) 解决方法之一: 将连接参数“host”的值由“localhost”改成“127.0.0.1”: 来源:https://www.cnblogs.com/Lam7/p/6090989.html mysql连接:ERROR 2002

解决MySQL报错ERROR 2002 (HY000)

今天在为新的业务线搭架数据库后,在启动的时候报错 [email protected]:/usr/local/mysql/bin# ./mysql ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) 在此记录一下,希望能够给遇到此问题的兄弟们提供一个解决问题的思路,有了思路后一步一步排查问题就比较容易了,但是我这个问题比较奇怪,如果有了解的兄