why I cannot cd into /var/lib/mysql
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
mysql
group has no access to that directory. The rights for the mysql
user are rwx
, but group and others get ---
, so being in the mysql
group doesn't give you what you want.