I am trying to connect to local mysql server I use for development
The server starts fine, but I can not connect to it as a non-root user.
[root@somepc ]# mysql -u [someuser] -p[somepass]
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (13 "Permission denied")
As root, this works as expected. So that user does have permissions to access mysql.
mysql -u [user] -p[password]
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 10.1.30-MariaDB MariaDB Server
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
When I check the permission of as my user
stat /var/lib/mysql/mysql.sock
stat: cannot stat '/var/lib/mysql/mysql.sock': Permission denied
What should these permission be for a non-root user?
Best Answer
The problem was related to the error on permissions on the socket file
As root I can see that the permissions on the socket file are
So the problem is the directory for mysql as can be seen above.
I fixed this by giving everybody access. As this is my local machine used for development.
On a production machine, I would consider the correct users to the mysql group.
Please use common sense and replace whatever you need between the
[]
aboveThis now works as expected