🚨ERROR

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

dog-pawwer 2024. 1. 18. 02:22
반응형

Mac에서 brew 를 통해 mysql를 install 하고 나서 해당 오류가 떴다.

이러한 에러는 MySQL이 MySQL 클라이언트가 연결하려는 로컬 MySQL 서버에 연결할 수 없을 때 발생한다.

MacBookPro ~ % mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

brew 서비스의 상태를 확인해보기 위해, 해당 명령어를 입력했다.

MySQL이 none으로 표시되었다면, 이는 Homebrew를 통해 MySQL 서비스가 현재 실행 중이지 않다는 것을 의미한다.

MacBookPro ~ % brew services list
Name    Status User File
mysql   none        
unbound none

따라서 mysql 서비스를 시작해야 한다.

brew services start mysql

-> mysql 서비스가 시작되었는지 확인

MacBookPro ~ % brew services start mysql
==> Successfully started `mysql` (label: homebrew.mxcl.mysql)

MacBookPro ~ % brew services list       
Name    Status  User  File
mysql   started jinho ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
unbound none          
jinho@gimjinhoui-MacBookPro ~ %

=> 다음과 같이
mysql -u root를 치면 mysql이 잘 작동하는 것을 알 수 있다.

MacBookPro ~ % mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.2.0 Homebrew

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
반응형