本文介绍了无法通过套接字'/var/mysql/mysql.sock'连接到本地MySQL服务器(38)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试连接mysql时遇到大问题.当我跑步时:

I am having a big problem trying to connect to mysql. When I run:

/usr/local/mysql/bin/mysql start

我遇到以下错误:

Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (38)

我在/var/mysql目录下确实有mysql.sock.

/etc/my.cnf中,我有:

[client]
port=3306
socket=/var/mysql/mysql.sock

[mysqld]
port=3306
socket=/var/mysql/mysql.sock
key_buffer_size=16M
max_allowed_packet=8M

/etc/php.ini中,我有:

; Default socket name for local MySQL connects.  If empty, uses the built-in
; MySQL defaults.
mysql.default_socket = /var/mysql/mysql.sock

我已经使用sudo /opt/local/apache2/bin/apachectl restart

但是我仍然有错误.

否则,我不知道这是否有意义,但是当我这样做时mysql_config --sockets我会得到

Otherwise, I don't know if that's relevant but when I do mysql_config --sockets I get

--socket         [/tmp/mysql.sock]

推荐答案

确保您正在运行mysqld:/etc/init.d/mysql start

Make sure you are running mysqld : /etc/init.d/mysql start

这篇关于无法通过套接字'/var/mysql/mysql.sock'连接到本地MySQL服务器(38)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 19:13