Socket error in MySQL installation

2

I am not able to uninstall and run MySql 5.5 on my Ubuntu Linux 14.04.LTS, every time I try to access it, I get the following message:

  

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

I have tried to start with the command: /etc/init.d/mysql start , but the problem persists. What am I doing wrong?

    
asked by anonymous 10.08.2015 / 20:21

3 answers

3

I am facing the same problem installing MySQL version 5.6 on Ubuntu 16.04 LTS. After searching and talking to friends, I figured out how to install it without error.

First, back up the databases and follow these commands:

$ sudo apt-get remove --purge *mysql/*
$ sudo apt-get autoremove
$ sudo apt-get autoclean
$ sudo rm -rf /var/lib/mysql
$ sudo apt install mysql-server-5.6
$ sudo apt install mysql-client-5.6
    
07.02.2018 / 13:02
2

Well, it's probably an issue regarding system permissions, or you have only installed mysql-client, but not mysql-server , so you can not create a UNIX Socket file.

So what you should try first is to install mysql-server:

$ sudo apt-get install mysql-server

If you are sure that mysql-server is installed, check the main configuration file, which in Debian and Ubuntu should be in /etc/mysql/my.cnf or /etc/my.cnf . In my Debian 7 is located at /etc/mysql/my.cnf . Your first part of the file should look like this:

Notice that under [client] there is a key called socket ? Well, this is the unix socket file that mysql uses for local connection, by default (unless you do not force it for TCP). If this file does not exist, create it:

$ sudo touch /var/run/mysqld/mysqld.sock

If it exists, try giving the appropriate permissions and looking at the user group:

$ sudo chown -R mysql:mysql /var/lib/mysql

As a final note, you could also connect using TCP, rather than UNIX socket.

    
10.08.2015 / 20:52
1

Well, I think I found the problem, and it was very simple, how I found the problem, it might help others, so I decided to publish the answer:

First I tried to remove the corrupted version: sudo apt-get remove mysql --purge . Then instead of installing " mysql-server-5.5 ", I just typed: sudo apt-get install mysql-server . And to finish, instead of giving a start , what I needed is restart to set the mysql initializer:
sudo /etc/init.d/mysql restart

After that, I still had to restart the MySQL service with the command:
sudo service mysql restart

And then everything worked again ...

    
10.08.2015 / 20:40