Score:0

Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (13) as non-root user

my flag
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?

Score:1
cn flag

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 avatar
cn flag
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)
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.