0
Can't connect to a local MySQL server through socket '/var/lib/mysql/mysql.sock' (13)

I am getting this message, but only when I am not logged in as root.

How come not everyone has access to mysql?

It doesn't work on user htorrent, and it works as root. I tried giving sudo permission, but it doesn't work. I am on the CENTOS 6.10 (final) version.

usermod -aG wheel htorrent

I tried the following, but it doesn't work. How do I give every user access to mysql?

Sayaman
  • 187
  • 1
  • 11

1 Answers1

1

The problem is caused by the socket having permissions which do not allow other users than root to connect to this socket. Please adjust the permissions of the socket in the mysql server configuration (most of the time its my.cnf somewhere in /etc ) or check the group that the socket is owned by, and add this user to this group, also remember to set appropriate group permissions in the configuration.

ls -la /var/lib/mysql/mysql.sock will show you the permissions and owner of the socket

bocian85
  • 822
  • 5
  • 10
  • alternatively you can make sure that `skip-networking` is not present in mysql configuration which will enable tcp port of the server, and then you can connect specyfing `127.0.0.1` instead of `localhost` as a server hostname when connecting. In mysql client `localhost` uses socket connection and `127.0.0.1` means TCP connection (which has no priviledge control other than user / password / hostname base) – bocian85 Jun 16 '21 at 07:08