Home > Database > Mysql Tutorial > body text

Linux 下 mysql 找不到 mysql.sock 文件的解决办法

WBOY
Release: 2016-06-07 17:17:51
Original
1564 people have browsed it

默认编译安装 mysql 的同学可能会遇到安装后普通用户连接不上 mysq server 的情况,报错ldquo;ERROR 2002 (HY000): Can

默认编译安装 mysql 的同学可能会遇到安装后普通用户连接不上 mysq server 的情况,报错

“ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysql/mysql.sock' (2)”

这个会让菜鸟很头疼,,经过本菜鸟的一番摸索,终于找解决方法。mysql.sock 文件默认是在 /tmp 目录下,但是可以通过 /etc/my.cnf 文件(关于这个文件是怎么来的,你在编译安装 mysql 的时候自然就知道哈)改变它的位置,只要指定 socket 变量即可:

“socket          = /var/run/mysql/mysql.sock”

或者在启动 mysql 的时候指定 --socket选项(-S 也一样):

$mysql --socket=/path/to/mysql.sock

很简单吧~~

linux

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