PHP file for test
<? Php
$ Link = mysql_connect ('localhost', 'root', 'zz ') or die (mysql_error ());
Mysql_select_db ('test') or die ('no db ');
Mysql_query ('set NAMES utf8 ');
Echo 99;
?>
Error reported after running
Can't connect to local MySQL server through socket '/tmp/mysql. sock'
However, you can access mysql in the command line.
[Root @ localhost local] # mysql-u root-p
Enter password:
Welcome to the MySQL monitor. Commands end with; or \ g. Your MySQL connection id is 3 Server version: 5.5.2-m2 Source distribution
Type 'help; 'or' \ H' for help. Type '\ C' to clear the buffer.
Mysql>
Solution
Chown-R root/usr/local/mysql
Chgrp-R mysql/usr/local/mysql
Chown-R root/usr/local/mysql/bin
Chgrp-R mysql/usr/local/mysql/bin
Chgrp-R mysql/var/lib/mysql
Chmod 777/var/lib/mysql
Chown-R root/var/lib/mysql
Chgrp-R mysql/var/lib/mysql
Chmod 777/var/lib/mysql
Chown-R root/var/lib/mysql /*
Chgrp-R mysql/var/lib/mysql /*
Chmod 777/var/lib/mysql /*
Chmod 777/usr/local/mysql/lib/mysql/libmysqlclient.