데이터베이스/MySQL
[MySQL] ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) 에러
기록하는 동구
2020. 8. 7. 18:23
반응형
Homebrew를 통해서 mysql을 설치하고 mysql을 실행시키자 마자 어김없이 날 찾아오는 에러!
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
도데체 뭐냐 넌 구글링 해보았다.
문제의 원인은 MySQL 이 설치는 되있지만 아직 실행이 안되있어서 그렇다.
mysql 서버를 실행시키는 방법을 알아보자! 방법은 2가지
첫번째, homebrew를 통해서 실행시켜보자.
$ brew services list
콘솔에 명령어를 입력해보면 mysql이 잘설치 되있음을 알수있다.
아래의 명령어로 mysql을 실행시켜 보자.
$ brew services start mysql
잘된다.
다시 꺼보자
$ brew services stop mysql
잘 꺼진다.
두번째 방법, 콘솔에다 명령어를 다르게 적어본다
$ mysql.server [start or stop]
그런데 실행후에 brew services list 하면 stopped 되있는걸 볼수있다. mysql.server 명령어로 실행시킨 mysql 이 명령어로 확인할수 없고
$ netstat -na | grep 3306
이걸로 확인해주면 된다. Mysql이 사용하는 포트는 3306이므로 파이프를 이용해 포트를 알려주면 쉽게 확인이 가능합니다.
이상 mysql server 실행방법이였습니당!
참고자료(reference) :
https://stackoverflow.com/questions/15450091/error-2002-hy000-cant-connect-to-local-mysql-server-through-socket-tmp-mys
https://freehoon.tistory.com/140
반응형