After mysql, apache, and php are successfully installed on Linux, a database connection is compiled. the following error is reported on the php page: CantconnecttolocalMySQLserverthroughsocketvarlibmysqlmysql. sock even searched the internet, which is still a typical error. I searched some information on google and solved it successfully. take the following steps:
After mysql, apache, and php are successfully installed on Linux, A. php page connecting to the database is compiled and the following error is reported:
Can't connect to local MySQL server through socket '/var/lib/mysql. sock'
I searched the internet for a typical error. I searched some information on google and successfully solved the problem. I used the following methods:
Check the mysql error log to see what is going on. The error log here is in/var/lib/mysql /*. err you will find that mysql cannot be started only because/var/lib/mysql does not allow access to the mysql service. by default, mysql calls the mysql User to start the service. As long
Chown-R mysql: mysql/var/lib/mysql
That's it. if it still cannot be started, you can debug the permission slowly. generally, it is a permission issue if it cannot be started.
If you still cannot start it, use my complicated permission settings. I do this every time. Generally, there is no problem. see:
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.