Home > Backend Development > PHP Tutorial > 安装使用MySQL时一个典型错误的解决_PHP

安装使用MySQL时一个典型错误的解决_PHP

WBOY
Release: 2016-06-01 12:29:37
Original
964 people have browsed it

mysql安装

偶在Linux上顺利安装mysql,apache,php之后,编了一个连接数据库的.php页面,报如下错误:
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'
偶在网上搜了下,还是个很典型的错误,偶在google上搜了一些资料,成功解决.偶采取如下方法:

看看mysql的错误日志就明白怎么回事,我这里的错误日志是在/var/lib/mysql/*.err 你会发现mysql只所以不能启动,是因为/var/lib/mysql的权限不允许mysql服务访问,英文mysql默认是调用mysql用户来启动服务的。我们只要
chown -R mysql:mysql /var/lib/mysql
就行,如果还是启动不了,再慢慢调试权限,反正一般启动不了都是权限的问题。

如果大家还是不能启动不了的话,那就用我的比较繁琐的权限的设置,反正我每次都是这么做的,一般不会有问题,见下:

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/mysql
chgrp -R mysql /var/lib/mysql/mysql
chmod 777 /var/lib/mysql/mysql
chown -R root /var/lib/mysql/mysql/*
chgrp -R mysql /var/lib/mysql/mysql/*
chmod 777 /var/lib/mysql/mysql/*
chmod 777 /usr/local/mysql/lib/mysql/libmysqlclient.a

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template