If anyone is still having problems try this.
assuming mysql.mysql owns all the db files in /var/lib/mysql and all commands are type from / and are logged in as root or have su to root.
if not: su root yourpassword
(so that mysql can create the domain sock file mysql.sock and so that php as a module of apache can access mysqld's mysql.sock.)
You see the thing is, if /var and /var/lib are set to 0700 then only root can read the mysql files, and if the user 'mysql' can't read the the /var or /var/lib directory's it can't find the /var/lib/mysql directory and therefore it can't create the domain socket /var/lib/mysql/mysql.sock
So to make it so, you have to give 'other' (the fourth digit) read access, and ofcourse execute access to 'cd' the directory. Without execute access on the directorys, mysqld run as mysql, cannot go: cd /var/lib/mysql... so to speak.
cd /
chmod 0755 /var
chmod 0755 /var/lib
chmod 0755 /var/lib/mysql
chown -R mysql.mysql /var/lib/mysql
also this helps:
( so that mysql can create the file mysqld.pid)
chmod 0755 /var/run/mysqld
chown -R mysql.mysql /var/run/mysqld
you can view the directory permission by doing this:
ls -ald /var/lib/mysql
-> drwxr-xr-x ## mysql mysql 4096 Feb 8 07:26 /var/lib/mysql
and: ls -al -> to view the permissions of files in the directory.
common access masks on files and directories.
0700 : drwx------ <-- not good for this purpose
only the user can view the contents of this directory, write or execute
group and other are just screwed.
0755 : drwxr-xr-x <-- what you want
( this is a directory, user can read, write, execute on to this directory, group and other can read and execute(cd ...), to this directory
0660 : -rw-rw---- common data file setting
( user and group can read+write to this file, but other is screwed)
I hope that helps! (otherwise I have had some good typing practice)
Cheers,
Jade