{"id":170,"date":"2016-08-01T09:21:42","date_gmt":"2016-08-01T04:51:42","guid":{"rendered":"http:\/\/www.enhisecure.com\/isecureblog\/?p=170"},"modified":"2016-11-17T11:14:37","modified_gmt":"2016-11-17T06:44:37","slug":"solving-the-problem-cant-connect-to-local-mysql-server-through-socket-varlibmysqlmysql-sock","status":"publish","type":"post","link":"https:\/\/www.enhisecure.com\/isecureblog\/2016\/08\/01\/solving-the-problem-cant-connect-to-local-mysql-server-through-socket-varlibmysqlmysql-sock\/","title":{"rendered":"Solving the problem &#8220;Can\u2019t connect to local MySQL server through socket &#8216;\/var\/lib\/mysql\/mysql.sock&#8217; \u201d"},"content":{"rendered":"<p><a href=\"http:\/\/www.mysql.com\/\">MySQL<\/a>\u00a0server\u00a0is usually connected by using the following command<\/p>\n<p style=\"text-align: center\"><strong>mysql \u00a0 \u00a0 \u00a0\u2013u \u00a0 \u00a0 \u00a0root \u00a0 \u00a0 \u00a0\u2013p<\/strong><\/p>\n<p>some times we may encounter the following the error<\/p>\n<p style=\"text-align: center\"><strong>can\u2019t connect to local MySQL server through socket \/var\/lib\/mysql\/mysql.sock<\/strong><\/p>\n<p>A <a href=\"http:\/\/man7.org\/linux\/man-pages\/man2\/socket.2.html\">socket <\/a>is used to bridge connection between the server and client.<\/p>\n<p>Error message explains that it is not able to find that <a href=\"http:\/\/man7.org\/linux\/man-pages\/man2\/socket.2.html\">socket <\/a>file.<\/p>\n<p><a href=\"http:\/\/man7.org\/linux\/man-pages\/man2\/socket.2.html\">Socket <\/a>file is automatically created when we start\u00a0the MySQL server and\u00a0disappears automatically when the server is stopped.<\/p>\n<p>This problem most probably arises when you accidentally delete it or if you reinstall same server again or because of server might not be running currently.<\/p>\n<p>Current running state of the server could be known using the following command<\/p>\n<p style=\"text-align: center\"><strong>service \u00a0 \u00a0 mysqld \u00a0 \u00a0 status<\/strong><\/p>\n<p>Use the following command to\u00a0solve the issue<\/p>\n<p style=\"text-align: center\"><strong>sudo \u00a0 \u00a0 \/etc\/init.d\/mysqld \u00a0 \u00a0 restart<\/strong><\/p>\n<p style=\"text-align: left\">The above command is used to restart the <a href=\"http:\/\/www.mysql.com\/\">MySQL <\/a>server so that the socket\u00a0file can be created.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>MySQL\u00a0server\u00a0is usually connected by using the following command mysql \u00a0 \u00a0 \u00a0\u2013u \u00a0 \u00a0 \u00a0root \u00a0 \u00a0 \u00a0\u2013p some times we may encounter the following the error can\u2019t connect to local MySQL server through socket \/var\/lib\/mysql\/mysql.sock A socket is used to bridge connection between the server and client. Error message explains that it is not [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-170","post","type-post","status-publish","format-standard","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/www.enhisecure.com\/isecureblog\/wp-json\/wp\/v2\/posts\/170","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.enhisecure.com\/isecureblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.enhisecure.com\/isecureblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.enhisecure.com\/isecureblog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.enhisecure.com\/isecureblog\/wp-json\/wp\/v2\/comments?post=170"}],"version-history":[{"count":6,"href":"https:\/\/www.enhisecure.com\/isecureblog\/wp-json\/wp\/v2\/posts\/170\/revisions"}],"predecessor-version":[{"id":176,"href":"https:\/\/www.enhisecure.com\/isecureblog\/wp-json\/wp\/v2\/posts\/170\/revisions\/176"}],"wp:attachment":[{"href":"https:\/\/www.enhisecure.com\/isecureblog\/wp-json\/wp\/v2\/media?parent=170"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.enhisecure.com\/isecureblog\/wp-json\/wp\/v2\/categories?post=170"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.enhisecure.com\/isecureblog\/wp-json\/wp\/v2\/tags?post=170"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}