MySQL suddenly stopped the LAMP stack

I use the LAMP stack in configuring Ubuntu.

It works fine, sets up several databases, everything goes well, and then all of a sudden this morning I started getting database errors from the web page I used, and then tried to access PHPMyAdmin:

error #2002 Cannot log in to the MySQL server 

I enter the bash prompt and try to log in as the root user sees that I am getting a similar error:

 ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111) 

I checked that there is a mysql.sock file that it does, at the specified path in the above error. Permissions where all is well and belongs to mysql. I reset permissions just in case and still get the same error.

Here is the file as seen from BASH:

 srwxrwxrwx 1 mysql mysql 0 Oct 21 05:10 mysqld.sock 

I thought I would just restart the service, but I get the same error when trying to stop, start, or restart the service.

It really baffled me, I am not an expert on Linux or something like that, but I donโ€™t understand how it can happen suddenly when I didnโ€™t change any configuration settings and it worked perfectly for the past few months.

I tried restarting Apache and got an error:

 apache2: bad user name ${APACHE_RUN_USER} 

I do not think this is due to MySQL stuff, but thought it might be related. The Apache bug seems to be more related to customization, but, knowing that my luck was lazy, made me ignore the simple things that made it all crash.

Any help to fix the problem and, more importantly, prevent this event will be very grateful for the future.

I tried most of the things that were returned by a basic Google search, and have a look here. I have not tried to delete and recreate the socks file yet, but most of the other things still havenโ€™t worked.

EDIT:

I just wanted to add that the Apache server is still working fine, there is nothing wrong with it, although I get an error when I try to stop and restart it. Pages that do not rely on MySQL still load without problems.

I also tried to kill mysql processes by searching for PID, and also, as suggested below, killall mysqld (as well as killall mysql only for hits). No processes were detected as a result of these attempts.

I donโ€™t know if this is relevant or not, but I cannot open (in vim) or view the mysqld.sock file (permission denied) even when using superuser.

+4
source share
3 answers

Have you tried using

 killall mysqld 

to kill a server and not just end the service and then start the MySQL service?

Or you can try uninstalling mysql.sock with

 rm /var/run/mysqld/mysqld.sock 

Then you just need to start the MySQL server again, either by starting the service, or by starting

 mysqld 

He should create a new /var/run/mysqld/mysqld.sock for himself, and everything should go well. Just a thought: this could be due to the computer being turned off correctly, or maybe MySQL was a little confused.

+4
source

Create one instance swap space in Ubuntu

dd if = / dev / zero of = / swapfile bs = 1M count = 1024

mkswap / swapfile

swapon / swapfile

+2
source

You tried to just restart the mysql server

 /etc/init.d/mysqld restart /etc/init.d/mysqld stop /etc/init.d/mysqld start 
+1
source

Source: https://habr.com/ru/post/1443896/


All Articles