Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why I cannot cd into /var/lib/mysql

The structure is the following

ravas@ravas-desk-lmde /var/lib $ pwd
/var/lib
ravas@ravas-desk-lmde /var/lib $ ls -l | grep mysql
drwx------ 13 mysql   mysql   4096 Feb 10 22:32 mysql

When I try to get into /var/lib/mysql, I don't have rights

ravas@ravas-desk-lmde /var/lib $ cd mysql/
bash: cd: mysql/: Permission denied

though I belong to the mysql group

ravas@ravas-desk-lmde /var/lib $ groups ravas 
ravas : ravas adm dialout cdrom floppy sudo audio dip video plugdev lpadmin sambashare mysql

What's the problem here?

like image 425
user3889486 Avatar asked Feb 11 '15 02:02

user3889486


People also ask

Where is the var lib file in mysql?

The default location for the Unix domain socket is /var/lib/mysql/mysql.

What is var lib mysql?

Usually /var/lib/mysql or /var/db/mysql directory used to store database and tales under UNIX like operating systems. You can use the following command to locate MySQL datadir: grep datadir /etc/my.cnf. datadir=/var/lib/mysql. Or.


2 Answers

sudo -i

then

cd /var/lib/mysql/
like image 145
zombie_ghast Avatar answered Oct 14 '22 19:10

zombie_ghast


mysql user is the only one that can access to the directory, you can use root to access there and change permissions, or you can change the directory permissions to 740 with

chmod 740 /var/lib/mysql

permissions are divided in 3 parts user/group/else. and you have

drwx------

d= directory

r= read = 4

w=write = 2

x=execute = 1

so the "owner" has read(4) + write(2) + execute(1) = 7 permissions in that directory

every one else doesn't

like image 23
Diego Velez Avatar answered Oct 14 '22 19:10

Diego Velez