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

델버·2022년 7월 15일
2

MariaDB

목록 보기
17/17

  • 이전 눈물겹게 macbook을 한번 밀었다. 그래서 MariaDB를 재설치 해야하는 상황에 error가 났는데 참으로 힘겨웠다.

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

  • 설치 후 sudo mariadb-secure-installation 를 하려할 때 이 에러가 났다. 원인은 server를 시작해주지 않아 생긴 일이었다. 평소 server를 자동으로 열게 설정해 놨기에 이 에러를 뵐 일이 없었다.
  • brew services start mariadb로 서버를 시작하자 다음 에러가 났다.

mariadb bootstrap failed: 5: input/output error try re-running the command as root for richer errors. error: failure while executing; /bin/launchctl bootstrap gui/501 /users/(이름검열)/library/launchagents/homebrew.mxcl.mariadb.plist exited with 5.

  • 이 에러에 찾아보니 my.cnf라는 mysql의 설정파일을 다시 설정해주거나 제거 후 다시 재설치하라고 한다.
  • my.cnf의 위치: mysql --verbose --help | grep my.cnf
  1. mysql 관련 파일 제거

rm -rf /usr/local/etc/my.cnf
rm -rf /usr/local/var/mysql

or 

rm -rf /opt/homebrew/etc/my.cnf
rm -rf /opt/homebrew/var/mysql
  1. MariaDB 재설치
    brew reinstall mariadb

  2. MariaDB 재시작
    brew services restart mariadb

  3. 이후에도 같은 에러가 나오면
    brew services stop mariadb brew services start mariadb

  4. 이후에도 같은 에러가 또 나오면
    만병통치약 재부팅 해라
    그랬더니 해결

여러 mysql 프로세스가 잡혀있어서 그런 듯하다.


참고

1개의 댓글

comment-user-thumbnail
2023년 7월 3일

진짜 너무 너무 감사합니다!!! 덕분에 해결했어요

답글 달기