Unable to connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' in Ubuntu 12.04.5 LTS

I encountered an error I can’t connect to the local MySQL server through the socket '/var/run/mysqld/mysqld.sock' in Ubuntu 12.04.5 LTS. So, I uninstalled mysql 5.5 from Ubuntu 12.04.5 LTS.But, when I tried to install mysql , I was unable to install mysql.

I used the following commands to uninstall mysql:

sudo apt-get remove --purge mysql-server mysql-client mysql-common sudo apt-get remove --purge mysql-server-5.5 mysql-client-5.5 mysql-servercore-5.5 mysql-client-core-5.5 sudo apt-get autoremove sudo apt-get autoclean sudo rm -rf /var/lib/mysql sudo rm -rf /etc/mysql sudo deluser mysql 

I used the following commands to install mysql 5.5:

 sudo apt-get install mysql-server-5.5 sudo apt-get install mysql-server 

But I ran into the following error:

  AppArmor parser error for /etc/apparmor.d/usr.sbin.mysqld in /etc/apparmor.d/usr.sbin.mysqld at line 9: Could not open 'abstractions/mysql' start: Job failed to start invoke-rc.d: initscript mysql, action "start" failed. dpkg: error processing mysql-server-5.5 (--configure): subprocess installed post-installation script returned error exit status 1 dpkg: dependency problems prevent configuration of mysql-server: mysql-server depends on mysql-server-5.5; however: Package mysql-server-5.5 is not configured yet. dpkg: error processing mysql-server (--configure): dependency problems - leaving unconfigured No apport report written because the error message indicates its a followup error from a previous failure. Errors were encountered while processing: mysql-server-5.5 mysql-server E: Sub-process /usr/bin/dpkg returned an error code (1) 

When I type 'mysql' from the terminal, it returns an error:

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

I tried telnet 127.0.0.1 3306 after googling, it returned refused .

Can anyone suggest a solution?

+5
source share
1 answer

Here is what fixed for me with Mariadb

First, find out if your mysql configuration file, most likely located in /etc/mysql/my.cnf or /etc/my.cnf , has the correct mysql.sock entry or not

You can find out where the mysql.sock file is located by running find / -type s , if the entry is incorrect in your mysql configuration, correct it, also make sure mysql.pid has the correct path.

Now try to start the mysql server, if it starts normally, and you can see all the DBs and tables inside, you are good and should not follow the rest of the message.

If mysql does not start after fixing the mysql.sock path, read

Add the following to my.cnf:

innodb_force_recovery = 1 inside the mysqld block and restart mysql.

If it does not start, increase the number by one each time, but keep in mind that after 3 there may be some data loss (not with me, but I just read about something above 3, which is a measure of salvation than recovery)

Do not panic if some of the tables that you previously had, stop showing that they do not exist in the engine. Ones mysql starts up successfully (if you don't already have a backup, better do it now, just in case you go south from here), remove innodb_force_recovery = 1 from my.cnf file and start mysql again, all your tables should be back up available.

Messages that helped me

+7
source

All Articles