<input type="hidden" id="_wpnonce" name="_wpnonce" value="9c395428d3" /><input type="hidden" name="_wp_http_referer" value="/blog/wp-json/wp/v2/posts/3540" /><input type="hidden" id="_wpnonce" name="_wpnonce" value="9c395428d3" /><input type="hidden" name="_wp_http_referer" value="/blog/wp-json/wp/v2/posts/3540" />{"id":3540,"date":"2015-06-28T10:56:59","date_gmt":"2015-06-28T00:56:59","guid":{"rendered":"https:\/\/www.businesslegions.com\/blog\/?p=3540"},"modified":"2015-06-28T10:56:59","modified_gmt":"2015-06-28T00:56:59","slug":"solved-cant-connect-local-mysql-server-socket-varlibmysqlmysql-sock","status":"publish","type":"post","link":"https:\/\/www.businesslegions.com\/blog\/2015\/06\/28\/solved-cant-connect-local-mysql-server-socket-varlibmysqlmysql-sock\/","title":{"rendered":"Solved: Can&#8217;t connect to local MySQL server through socket &#8216;\/var\/lib\/mysql\/mysql.sock&#8217;"},"content":{"rendered":"<!--CusAds0--><p>My VPS server experienced an issue with mySQL server and thought I&#8217;d better document how to resolve it in case it happens again.<\/p>\n<h2>The symptoms<\/h2>\n<ul>\n<li>An Error message saying unable to connect to the database comes up when trying to access websites using WordPress<\/li>\n<li>Manually starting the mysqld came back with &#8220;Failed&#8221;- using the command<\/li>\n<\/ul>\n<div id=\"wpshdo_1\" class=\"wp-synhighlighter-outer\"><div id=\"wpshdt_1\" class=\"wp-synhighlighter-expanded\"><table border=\"0\" width=\"100%\"><tr><td align=\"left\" width=\"80%\"><a name=\"#codesyntax_1\"><\/a><a id=\"wpshat_1\" class=\"wp-synhighlighter-title\" href=\"#codesyntax_1\"  onClick=\"javascript:wpsh_toggleBlock(1)\" title=\"Click to show\/hide code block\">Source code<\/a><\/td><td align=\"right\"><a href=\"#codesyntax_1\" onClick=\"javascript:wpsh_code(1)\" title=\"Show code only\"><img decoding=\"async\" border=\"0\" style=\"border: 0 none\" src=\"https:\/\/cdn.businesslegions.com\/blog\/wp-content\/plugins\/wp-synhighlight\/themes\/default\/images\/code.png?strip=all&w=960\" \/><\/a>&nbsp;<a href=\"#codesyntax_1\" onClick=\"javascript:wpsh_print(1)\" title=\"Print code\"><img decoding=\"async\" border=\"0\" style=\"border: 0 none\" src=\"https:\/\/cdn.businesslegions.com\/blog\/wp-content\/plugins\/wp-synhighlight\/themes\/default\/images\/printer.png?strip=all&w=960\" \/><\/a>&nbsp;<a href=\"https:\/\/www.businesslegions.com\/blog\/wp-content\/plugins\/wp-synhighlight\/About.html\" target=\"_blank\" title=\"Show plugin information\"><img decoding=\"async\" border=\"0\" style=\"border: 0 none\" src=\"https:\/\/cdn.businesslegions.com\/blog\/wp-content\/plugins\/wp-synhighlight\/themes\/default\/images\/info.gif?strip=all&w=960\" \/><\/a>&nbsp;<\/td><\/tr><\/table><\/div><div id=\"wpshdi_1\" class=\"wp-synhighlighter-inner\" style=\"display: block;\"><pre class=\"php\" style=\"font-family:monospace;\">service mysqld restart<\/pre><\/div><\/div>\n<ul>\n<li>Rebooting didn&#8217;t fix the problem<\/li>\n<li>When trying to run &#8220;mysql&#8221; an error message came back with<br \/>\n<div id=\"wpshdo_2\" class=\"wp-synhighlighter-outer\"><div id=\"wpshdt_2\" class=\"wp-synhighlighter-expanded\"><table border=\"0\" width=\"100%\"><tr><td align=\"left\" width=\"80%\"><a name=\"#codesyntax_2\"><\/a><a id=\"wpshat_2\" class=\"wp-synhighlighter-title\" href=\"#codesyntax_2\"  onClick=\"javascript:wpsh_toggleBlock(2)\" title=\"Click to show\/hide code block\">Source code<\/a><\/td><td align=\"right\"><a href=\"#codesyntax_2\" onClick=\"javascript:wpsh_code(2)\" title=\"Show code only\"><img decoding=\"async\" border=\"0\" style=\"border: 0 none\" src=\"https:\/\/cdn.businesslegions.com\/blog\/wp-content\/plugins\/wp-synhighlight\/themes\/default\/images\/code.png?strip=all&w=960\" \/><\/a>&nbsp;<a href=\"#codesyntax_2\" onClick=\"javascript:wpsh_print(2)\" title=\"Print code\"><img decoding=\"async\" border=\"0\" style=\"border: 0 none\" src=\"https:\/\/cdn.businesslegions.com\/blog\/wp-content\/plugins\/wp-synhighlight\/themes\/default\/images\/printer.png?strip=all&w=960\" \/><\/a>&nbsp;<a href=\"https:\/\/www.businesslegions.com\/blog\/wp-content\/plugins\/wp-synhighlight\/About.html\" target=\"_blank\" title=\"Show plugin information\"><img decoding=\"async\" border=\"0\" style=\"border: 0 none\" src=\"https:\/\/cdn.businesslegions.com\/blog\/wp-content\/plugins\/wp-synhighlight\/themes\/default\/images\/info.gif?strip=all&w=960\" \/><\/a>&nbsp;<\/td><\/tr><\/table><\/div><div id=\"wpshdi_2\" class=\"wp-synhighlighter-inner\" style=\"display: block;\"><pre class=\"php\" style=\"font-family:monospace;\">Can<span class=\"st_h\">'t connect to local MySQL server through socket '<\/span><span class=\"sy0\">\/<\/span><span class=\"kw2\">var<\/span><span class=\"sy0\">\/<\/span>lib<span class=\"sy0\">\/<\/span><a href=\"http:\/\/www.php.net\/mysql\"><span class=\"kw3\">mysql<\/span><\/a><span class=\"sy0\">\/<\/span><a href=\"http:\/\/www.php.net\/mysql\"><span class=\"kw3\">mysql<\/span><\/a><span class=\"sy0\">.<\/span>sock<span class=\"st_h\">'<\/span><\/pre><\/div><\/div><\/li>\n<\/ul>\n<h2>The solution<\/h2>\n<p>For some reason this worked for me &#8211; it may not work for you. \u00a0All you have to do is run the database in recovery mode so follow these instructions:<\/p>\n<p>SSH into your VPS server<\/p>\n<p>Edit the my.cnf file in the folder \/etc and add the following line:<\/p>\n<div id=\"wpshdo_3\" class=\"wp-synhighlighter-outer\"><div id=\"wpshdt_3\" class=\"wp-synhighlighter-expanded\"><table border=\"0\" width=\"100%\"><tr><td align=\"left\" width=\"80%\"><a name=\"#codesyntax_3\"><\/a><a id=\"wpshat_3\" class=\"wp-synhighlighter-title\" href=\"#codesyntax_3\"  onClick=\"javascript:wpsh_toggleBlock(3)\" title=\"Click to show\/hide code block\">Source code<\/a><\/td><td align=\"right\"><a href=\"#codesyntax_3\" onClick=\"javascript:wpsh_code(3)\" title=\"Show code only\"><img decoding=\"async\" border=\"0\" style=\"border: 0 none\" src=\"https:\/\/cdn.businesslegions.com\/blog\/wp-content\/plugins\/wp-synhighlight\/themes\/default\/images\/code.png?strip=all&w=960\" \/><\/a>&nbsp;<a href=\"#codesyntax_3\" onClick=\"javascript:wpsh_print(3)\" title=\"Print code\"><img decoding=\"async\" border=\"0\" style=\"border: 0 none\" src=\"https:\/\/cdn.businesslegions.com\/blog\/wp-content\/plugins\/wp-synhighlight\/themes\/default\/images\/printer.png?strip=all&w=960\" \/><\/a>&nbsp;<a href=\"https:\/\/www.businesslegions.com\/blog\/wp-content\/plugins\/wp-synhighlight\/About.html\" target=\"_blank\" title=\"Show plugin information\"><img decoding=\"async\" border=\"0\" style=\"border: 0 none\" src=\"https:\/\/cdn.businesslegions.com\/blog\/wp-content\/plugins\/wp-synhighlight\/themes\/default\/images\/info.gif?strip=all&w=960\" \/><\/a>&nbsp;<\/td><\/tr><\/table><\/div><div id=\"wpshdi_3\" class=\"wp-synhighlighter-inner\" style=\"display: block;\"><pre class=\"php\" style=\"font-family:monospace;\">innodb_force_recovery <span class=\"sy0\">=<\/span> <span class=\"nu0\">1<\/span><\/pre><\/div><\/div>\n<p>Then save the file<\/p>\n<p>Restart mysqld by using the following command:<\/p>\n<div id=\"wpshdo_4\" class=\"wp-synhighlighter-outer\"><div id=\"wpshdt_4\" class=\"wp-synhighlighter-expanded\"><table border=\"0\" width=\"100%\"><tr><td align=\"left\" width=\"80%\"><a name=\"#codesyntax_4\"><\/a><a id=\"wpshat_4\" class=\"wp-synhighlighter-title\" href=\"#codesyntax_4\"  onClick=\"javascript:wpsh_toggleBlock(4)\" title=\"Click to show\/hide code block\">Source code<\/a><\/td><td align=\"right\"><a href=\"#codesyntax_4\" onClick=\"javascript:wpsh_code(4)\" title=\"Show code only\"><img decoding=\"async\" border=\"0\" style=\"border: 0 none\" src=\"https:\/\/cdn.businesslegions.com\/blog\/wp-content\/plugins\/wp-synhighlight\/themes\/default\/images\/code.png?strip=all&w=960\" \/><\/a>&nbsp;<a href=\"#codesyntax_4\" onClick=\"javascript:wpsh_print(4)\" title=\"Print code\"><img decoding=\"async\" border=\"0\" style=\"border: 0 none\" src=\"https:\/\/cdn.businesslegions.com\/blog\/wp-content\/plugins\/wp-synhighlight\/themes\/default\/images\/printer.png?strip=all&w=960\" \/><\/a>&nbsp;<a href=\"https:\/\/www.businesslegions.com\/blog\/wp-content\/plugins\/wp-synhighlight\/About.html\" target=\"_blank\" title=\"Show plugin information\"><img decoding=\"async\" border=\"0\" style=\"border: 0 none\" src=\"https:\/\/cdn.businesslegions.com\/blog\/wp-content\/plugins\/wp-synhighlight\/themes\/default\/images\/info.gif?strip=all&w=960\" \/><\/a>&nbsp;<\/td><\/tr><\/table><\/div><div id=\"wpshdi_4\" class=\"wp-synhighlighter-inner\" style=\"display: block;\"><pre class=\"php\" style=\"font-family:monospace;\">service mysqld restart<\/pre><\/div><\/div>\n<p>It should now work. If the server started with OK then it worked.<\/p>\n<p>Go back and disable the innodb recovery by either removing the line or just adding a # at the front.<\/p>\n<p>Hopefully this has fixed your issue.<\/p>\n<p><a href=\"https:\/\/cdn.businesslegions.com\/blog\/wp-content\/uploads\/2015\/06\/Cant-connect-to-local-MySQL-server-through-socket.png?strip=all&w=2560\"><img decoding=\"async\" class=\"alignnone size-full wp-image-3571\" src=\"https:\/\/cdn.businesslegions.com\/blog\/wp-content\/uploads\/2015\/06\/Cant-connect-to-local-MySQL-server-through-socket.png?strip=all\" alt=\"Cant connect to local MySQL server through socket\" width=\"475\" height=\"347\" srcset=\"https:\/\/cdn.businesslegions.com\/blog\/wp-content\/uploads\/2015\/06\/Cant-connect-to-local-MySQL-server-through-socket.png?strip=all 475w, https:\/\/cdn.businesslegions.com\/blog\/wp-content\/uploads\/2015\/06\/Cant-connect-to-local-MySQL-server-through-socket-300x219.png?strip=all 300w, https:\/\/cdn.businesslegions.com\/blog\/wp-content\/uploads\/2015\/06\/Cant-connect-to-local-MySQL-server-through-socket.png?strip=all&amp;w=95 95w, https:\/\/cdn.businesslegions.com\/blog\/wp-content\/uploads\/2015\/06\/Cant-connect-to-local-MySQL-server-through-socket.png?strip=all&amp;w=190 190w, https:\/\/cdn.businesslegions.com\/blog\/wp-content\/uploads\/2015\/06\/Cant-connect-to-local-MySQL-server-through-socket.png?strip=all&amp;w=380 380w\" sizes=\"(max-width: 475px) 100vw, 475px\" \/><\/a><\/p>\n<div class=\"lt-box\" style=\"border:1px solid #1a4ccc\"><div class=\"lt-box-title\" style=\"background-color:#215fff;border-top:1px solid #a6bfff;text-shadow:1px 1px 0 #0a1c4c\">RESOURCES<\/div><div class=\"lt-box-content\">Here&#8217;s a list of resources that you might find useful:<\/p>\n<p>More information about innodb force recovery: <a href=\"https:\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/forcing-innodb-recovery.html\" target=\"_blank\">Click here<\/a><\/p>\n<\/div><\/div>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<div class=\"lt-box\" style=\"border:1px solid #1d6a9e\"><div class=\"lt-box-title\" style=\"background-color:#2485C6;border-top:1px solid #a7cee8;text-shadow:1px 1px 0 #0b283b\">DO YOU LIKE WHAT YOU'VE READ?<\/div><div class=\"lt-box-content\">Join our subscription list and receive our content right in your mailbox. If you like to receive some Great deals our Freebies then subscribe now!\r\n\r\n<p><div class=\"tnp tnp-subscription \">\n<form method=\"post\" action=\"https:\/\/www.businesslegions.com\/blog\/wp-admin\/admin-ajax.php?action=tnp&amp;na=s\">\n<input type=\"hidden\" name=\"nlang\" value=\"\">\n<div class=\"tnp-field tnp-field-firstname\"><label for=\"tnp-1\">Name<\/label>\n<input class=\"tnp-name\" type=\"text\" name=\"nn\" id=\"tnp-1\" value=\"\" placeholder=\"\"><\/div>\n<div class=\"tnp-field tnp-field-email\"><label for=\"tnp-2\">Email<\/label>\n<input class=\"tnp-email\" type=\"email\" name=\"ne\" id=\"tnp-2\" value=\"\" placeholder=\"\" required><\/div>\n<div class=\"tnp-field tnp-field-button\" style=\"text-align: left\"><input class=\"tnp-submit\" type=\"submit\" value=\"Subscribe\" style=\"\">\n<\/div>\n<\/form>\n<\/div>\n<\/p>\r\n\r\n<\/div><\/div><!--CusAds0-->\n<div style=\"font-size: 0px; height: 0px; line-height: 0px; margin: 0; padding: 0; clear: both;\"><\/div>","protected":false},"excerpt":{"rendered":"<p>My VPS server experienced an issue with mySQL server and thought I&#8217;d better document how to resolve it in case it happens again. The symptoms An Error message saying unable to connect to the database comes up when trying to access websites using WordPress Manually starting the mysqld came back with &#8220;Failed&#8221;- using the command [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3571,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[1640,747,174,51],"class_list":["post-3540","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology","tag-back","tag-mysql","tag-recovery","tag-work"],"_links":{"self":[{"href":"https:\/\/www.businesslegions.com\/blog\/wp-json\/wp\/v2\/posts\/3540","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.businesslegions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.businesslegions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.businesslegions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.businesslegions.com\/blog\/wp-json\/wp\/v2\/comments?post=3540"}],"version-history":[{"count":7,"href":"https:\/\/www.businesslegions.com\/blog\/wp-json\/wp\/v2\/posts\/3540\/revisions"}],"predecessor-version":[{"id":28034,"href":"https:\/\/www.businesslegions.com\/blog\/wp-json\/wp\/v2\/posts\/3540\/revisions\/28034"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.businesslegions.com\/blog\/wp-json\/wp\/v2\/media\/3571"}],"wp:attachment":[{"href":"https:\/\/www.businesslegions.com\/blog\/wp-json\/wp\/v2\/media?parent=3540"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.businesslegions.com\/blog\/wp-json\/wp\/v2\/categories?post=3540"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.businesslegions.com\/blog\/wp-json\/wp\/v2\/tags?post=3540"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}