본문 바로가기
IT

Mysql socket error

by Oh.mogilalia 2021. 8. 14.

ERROR 2002 (HY000): Can't connect to local MySQL server through socket

sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf

user = mysql
pid-file = /run/mysqld/mysqld.pid
socket = /run/mysqld/mysqld.sock
#port = 3306
basedir = /usr
datadir = /home/mogibu/apm/www/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql

Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)
1. Create the directory (if it doesn’t already exist).
#sudo mkdir /var/run/mysqld/

2. Create the file by “touching”
#sudo touch /var/run/mysqld/mysqld.sock

3. Set the ownership of the mysqld.sock file and folder to mysql.
#sudo chown -R mysql /var/run/mysqld/

4. Start mysql:
/etc/init.d/mysql restart

If this solution isn’t work then you have to look at my.cnf file which it can make you confused. Replacing my.cnf with original one is better.

8. mysql sock 에러 문제의 확실한 해결법
Q : 접속하면 >/var/lib/mysql/mysql.sock ... (111)

A : 디렉토리 퍼미션 문제
# killall mysqld
# chmod 755 -R /var/lib/mysql
# chown mysql.mysql -R /var/lib/mysql
# mysqld_safe --language=korean &
-----------------------------------------------
에러를 해결이 안되네. 일일이 mysqld_safe --language=korean & 하기도 귀찮고 해서 혹시나 하고 mariadb 디렉토리를 원래대로 되돌렸다.

'IT' 카테고리의 다른 글

구글 폰트 적용  (0) 2021.08.18
망보드 도움글  (0) 2021.08.15
The REST API did not process the context query parameter correctly.  (0) 2021.08.14
워드프레스 참고 사이트  (0) 2021.08.11
워드프레스 참조  (0) 2021.08.11