我有一个大问题试图连接到mysql。当我跑步时:

/usr/local/mysql/bin/mysql start

我有以下错误:

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

我有mysql。Sock在/var/mysql目录下。

在/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重启apache

但还是有误差。

否则,我不知道这是否相关,但当我执行mysql_config——sockets时,我得到

--socket         [/tmp/mysql.sock]

当前回答

我已经删除了mysql。袜子锉成功了。给它加上版权根本没用。既不是重启,也不是别的……

其他回答

我得到了以下错误:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)

尝试了几种方法,最终通过以下方法解决:

sudo gksu gedit /etc/mysql/my.cnf

修改:

#bind-address       = 127.0.0.1

to:

bind-address        = localhost

并重新启动:

sudo /etc/init.d/mysql restart

它工作。

添加

--protocol=tcp 

跟你联系的那些偷车贼都对我有用。

我刚刚遇到了这个问题。经过一天的检查,我终于得到了答案,mysql。sock文件在MariaDB启动时创建,在MariaDB关闭时删除。如果MariaDB不运行,它就不存在。 也许你没有安装MariaDB。 你可以按照下面的说明操作: https://www.linode.com/docs/databases/mariadb/how-to-install-mariadb-on-centos-7 最好的

我得到这个错误是因为我正在运行MAMP,而我的.sock文件在不同的位置。我只是在应用程序认为应该指向实际位置的地方添加了一个符号链接,效果很好。

我今天遇到了这个问题。这些答案都不能解决问题。我需要做以下命令(在这里找到https://stackoverflow.com/a/20141146/633107)为我的mysql服务启动:

sudo /etc/init.d/mysql stop
cd /var/lib/mysql/
ls ib_logfile*
mv ib_logfile0 ib_logfile0.bak
mv ib_logfile1 ib_logfile1.bak
... etc ...
/etc/init.d/mysql restart

这部分是由/var/log/mysql/error.log中的以下错误指示的:

140319 11:58:21 InnoDB: Completed initialization of buffer pool
InnoDB: Error: log file ./ib_logfile0 is of different size 0 50331648 bytes
InnoDB: than specified in the .cnf file 0 5242880 bytes!
140319 11:58:21 [ERROR] Plugin 'InnoDB' init function returned error.
140319 11:58:21 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
140319 11:58:21 [ERROR] Unknown/unsupported storage engine: InnoDB
140319 11:58:21 [ERROR] Aborting

我还看到磁盘已满错误,但只有在运行没有sudo的命令时。如果权限检查失败,则报告磁盘已满(即使您的分区还没有接近满)。