问题描述
我迁移到一台新计算机上,并使用迁移助手在我的文件之间复制(这似乎在数据库之间复制),但是我不得不使用macports安装Mysql(而上次我是通过Dan Benjamin的指南从源代码编译的).由于某种原因,mysql间歇性地引发以下错误;
I migrated to a new machine and used migration assistant to copy across my files (which seemed to copy across the DBs) but I had to use macports to install Mysql (whereas last time I compiled from source via Dan Benjamin's guide). For some reason, mysql is intermittently throwing the following error;
无法通过套接字'/opt/local/var/run/mysql5/mysqld.sock'(2)连接到本地MySQL服务器
Can't connect to local MySQL server through socket '/opt/local/var/run/mysql5/mysqld.sock' (2)
无论我尝试什么,它都会这样做,其中包括在/opt/local/etc/mysql5/my.cnf中设置套接字.以前,我已经设法通过重新启动计算机来临时解决此问题,但是尽管grep mysql告诉我我似乎有一个pid,但现在它只是不想知道.
It does this no matter what I try, which has included setting the socket in /opt/local/etc/mysql5/my.cnf. Previously I've managed to temporarily fix this by restarting the machine, but right now it just doesn't want to know, despite grep mysql telling me I seem to have a pid;
0 46 1 0 0:00.01 ?? 0:00.01 /opt/local/bin/daemondo --label=mysql5 --start-cmd /opt/local/etc/LaunchDaemons/org.macports.mysql5/mysql5.wrapper start ; --stop-cmd /opt/local/etc/LaunchDaemons/org.macports.mysql5/mysql5.wrapper stop ; --restart-cmd /opt/local/etc/LaunchDaemons/org.macports.mysql5/mysql5.wrapper restart ; --pid=none
0 70 1 0 0:00.01 ?? 0:00.01 /bin/sh /opt/local/lib/mysql5/bin/mysqld_safe --datadir=/opt/local/var/db/mysql5 --pid-file=/opt/local/var/db/mysql5/localhost.pid
74 100 70 0 0:09.22 ?? 1:02.68 /opt/local/libexec/mysqld --basedir=/opt/local --datadir=/opt/local/var/db/mysql5 --user=mysql --pid-file=/opt/local/var/db/mysql5/localhost.pid --socket=/tmp/mysql.sock
501 66217 65266 0 0:00.00 ttys001 0:00.00 grep mysql
我该如何解决?接下来我有什么步骤可以采取?我已经尝试了几个星期,并且已经阅读了所有相关的博客文章,所以我完全没有主意.
How do I fix this? Are there any steps I can take next? I've been trying for a few weeks now and I've read round all relevant blog posts, so I'm completely out of ideas.
推荐答案
这是事实之后的方法,但这是我所做的:
This is way after the fact, but here's what I did:
touch /opt/local/var/run/mysql5/mysqld.sock
vi /opt/local/etc/mysql5/my.cnf
将以下行添加到my.cnf
:
[mysqld_safe]
socket = /opt/local/var/run/mysql5/mysqld.sock
[client]
socket = /opt/local/var/run/mysql5/mysqld.sock
这应该允许您连接.这对豹子和雪豹都有效.
This should allow you to connect. This worked for me on both Leopard and Snow Leopard.
这篇关于在豹子上安装mysql:“无法通过套接字连接到本地MySQL服务器"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!