无法通过套接字 '/var/mysql/mysql.sock' 连接到本地 MySQL 服务器 (38)

2022-01-30 00:00:00 mysql

我在尝试连接 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.

I do have mysql.sock under the /var/mysql directory.

/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

相关文章