Apr 28, 2018 - Connect Error: Can't connect to local MySQL server through socket '/var/lib/mysql'

Connect Error: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)

mysql 오류

mysql로 localhost에 접속하려고 할 때, 다음과 같은 오류가 발생했습니다.

$ mysql -uroot
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)

인터넷을 통해 해결방법을 찾아보았는데, root 계정으로 symbolic link 설정하라는 글을 봤습니다.

$ ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock

그렇게 했는데도 처리가 안됩니다. 여러가지 방법을 사용해봤는데, 데이터베이스가 전체적으로 깨진것으로 파악되며, 아예 전부 리셋하지 않으면 방법이 없어보입니다.

개인서버이며, mysql 에서 mariadb로 변환하면서 생긴 오류로 파악되어, 인터넷의 여러방법을 찾아봤지만, 해결책을 찾을 수 없었습니다.

어쩔 수없이, crontab -e 에 1분간 shell script 를 등록했습니다.

* * * * * sh /home/mysql_start.sh

별도의 쉘스크립트를 생성하였고, 해당 스크립트는,

/usr/sbin/service mysql start >> /home/mysql.log 2>&1

1분마다 계속 mysql 을 start 시킵니다. 라이브 운영되는 서버라면 mariadb를 dump 하여 다시 마이그레이션처리를 해야할 이슈로 보입니다.

Dec 5, 2017 - tomcat 최신버전 업그레이드 할 때 유의점

파라미터를 “|” 로 넘기는 경우에 대해 tomcat에서 막음.

CVE-2016-6816 관련 에러가 발생할 경우, catalina.properties 에서 tomcat.util.http.parser.HttpParser.requestTargetAllow= 를 주석 제거함.
# Allow for changes to HTTP request validation
# WARNING: Using this option will expose the server to CVE-2016-6816
 tomcat.util.http.parser.HttpParser.requestTargetAllow=|

해당 에러는 get 방식에서만 발생했고, post 방식이나 restful의 body 형태로 값을 넘기는 경우 필요가 없음.

[Since Tomcat 7.0.76, 8.0.42, 8.5.12 you can define property requestTargetAllow to allow forbiden characters.] 위의 버전부터 처리해당 기능 추가.


추후 여러가지 특수문자에 대한 파라미터를 제거하기 위해 계속 추가된 최종 형태

tomcat.util.http.parser.HttpParser.requestTargetAllow=^_|{}#$%@!:&()[],.^

get 방식에 encoding 없이 바로 넘기는 건 지양해야함. 2번, 3번 동일 특수문자가 encoding 없이 다시 호출되면 CVE-2016-6816 관련 에러가 재발됨.

쿠키 관련 허용에 대한 처리 로직

context.xml 쿠키 관련 허용에 대한 처리해야합니다.

<CookieProcessor className="org.apache.tomcat.util.http.LegacyCookieProcessor" />

참고주소
쿠키를 사용하지 않을 경우에는 해당 기능에 대하여 추가 될 필요 없음.

tomcat 버전업시 해당 부분에 대해 참고!

2020-01-02 년 내용 추가합니다.

<Connector port="80" protocol="HTTP/1.1"
           connectionTimeout="20000" URIEncoding="UTF-8"
           redirectPort="8443" relaxedPathChars="[]|" relaxedQueryChars="[]|{}^&#x5c;&#x60;&quot;&lt;&gt;" />

상위버전부터 tomcat.util.http.parser.HttpParser.requestTargetAllow 도 Deprecated 되었다고 하며, server.xml 의 relaxedPathChars 와 relaxedQueryChars 에 해당 문자를 추가하여 대응가능합니다.

Nov 29, 2017 - null; nested exception is org.apache.http.client.ClientProtocolException

null; nested exception is org.apache.http.client.ClientProtocolException

중간에 리다이렉트 조건이 존재할 경우, HttpClient에서 ClientProtocolException이 일어날 수 있습니다.