Mysql 시작 오류: 2002 분석 문제를 해결하는 방법

黄舟
풀어 주다: 2017-09-02 13:28:02
원래의
1510명이 탐색했습니다.

이 글에서는 주로 Mysql 스타트업 ERROR: 2002 문제에 대한 분석과 해결 방법을 소개하며, 샘플 코드를 통해 문제를 자세히 분석하고, 이 문제에 직면한 친구들을 위한 참고 학습도 제공합니다. 도움이 필요한 친구들이 와서 아래를 살펴보세요.

머리말

이 글은 주로 MySQL 시작 오류 ERROR: 2002에 대한 분석과 해결 방법을 소개하며, 참고 및 학습을 위해 공유합니다. 아래에서는 자세히 설명하지 않겠습니다. 자세한 소개.

1. 장애 현상


[root@localhost scripts]# mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysqld.sock' (2)
로그인 후 복사

2. 장애 분석

mysql 인스턴스 상태 보기


[root@localhost scripts]# netstat -ntlp | grep 3306
tcp 0 0 :::3306   :::*   LISTEN 13001/mysqld
로그인 후 복사

소켓에 대한 my.cnf 구성 보기


[root@localhost scripts]# more /etc/my.cnf |grep sock
socket = /tmp/mysqld.sock
로그인 후 복사

즉, mysqld는 올바른 양말 파일을 요청했지만 클라이언트 연결은 여전히 ​​초기 디렉터리에서 양말 파일을 찾습니다.

아래 배경 로그를 확인하세요. 전체 쿼리 로그 때문입니다. 디렉토리가 존재하지 않아 발생한 오류는 현재 오류와 관련이 없습니다


[root@localhost scripts]# more SZDB.err
  ............
2014-10-11 13:17:21 13001 [Note] InnoDB: 5.6.12 started; log sequence number 1625997
/app/soft/mysql/bin/mysqld: File '/log/mysql_logs/slowquery.log' not found (Errcode: 2 - No such file or directory)
2014-10-11 13:17:21 13001 [ERROR] Could not use /log/mysql_logs/slowquery.log for logging (error 2). Turning logging off for the who
le duration of the MySQL server process. To turn it on again: fix the cause, shutdown the MySQL server and restart it.
2014-10-11 13:17:21 13001 [Note] Server hostname (bind-address): '*'; port: 3306
2014-10-11 13:17:21 13001 [Note] IPv6 is available.
2014-10-11 13:17:21 13001 [Note] - '::' resolves to '::';
2014-10-11 13:17:21 13001 [Note] Server socket created on IP: '::'.
2014-10-11 13:17:21 13001 [Note] Event Scheduler: Loaded 0 events
2014-10-11 13:17:21 13001 [Note] /app/soft/mysql/bin/mysqld: ready for connections.
Version: '5.6.12-log' socket: '/tmp/mysql.sock' port: 3306 Source distribution
#Author :Leshami
#Blog : http://www.linuxidc.com
로그인 후 복사

3. 오류를 구성하여 해결하세요. my.cnf mysql 옵션 소켓 파일 위치
mysql 서버를 먼저 중지하세요


[root@localhost scripts]# systemvtl restart mysqld
Shutting down MySQL.[ OK ]
로그인 후 복사

my.cnf를 다음과 같이 수정하세요


[root@localhost scripts]# vi /etc/my.cnf
[mysql]
no-auto-rehash
socket = /tmp/mysqld.sock #添加该行
로그인 후 복사

mysql 서버를 다시 시작하세요


[root@localhost scripts]# systemctl restart mysqld 
Starting MySQL..[ OK ]
로그인 후 복사

정상적으로 다시 연결하세요


[root@localhost scripts]# mysql -uroot -p
Enter password:
mysql> show variables like 'version';
+---------------+------------+
| Variable_name | Value |
+---------------+------------+
| version | 5.6.12-log |
+---------------+------------+
로그인 후 복사

b. 소켓 파일에 대한 링크 방법 설정


[root@SZDB mysqldata]# ln -s /tmp/mysql.sock /data/mysqldata/mysql.sock
ln: creating symbolic link `/data/mysqldata/mysql.sock' to `/tmp/mysql.sock': File exists
[root@SZDB mysqldata]# rm mysql.sock #上面提示文件存在,所以删除之前的mysql.sock文件
[root@SZDB mysqldata]# ln -s /tmp/mysql.sock /data/mysqldata/mysql.sock
[root@SZDB mysqldata]# ls -hltr mysql.sock
lrwxrwxrwx 1 root root 15 Oct 11 14:00 mysql.sock -> /tmp/mysql.sock
[root@SZDB mysqldata]# mysql -uroot -p
Enter password:
mysql> show variables like 'socket';
+---------------+-----------------+
| Variable_name | Value  |
+---------------+-----------------+
| socket | /tmp/mysql.sock |
+---------------+-----------------+
로그인 후 복사

요약

위 내용은 Mysql 시작 오류: 2002 분석 문제를 해결하는 방법의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!