MySQL地狱...无法连接到数据库/tmp/mysql.sock [英] MySQL hell... can't connect to database /tmp/mysql.sock
问题描述
更新:我已经停止了正在运行的旧版mysql进程,并引起了一些混乱.现在我认为我只运行较新的(5.1.40)版本.但是,它指向错误的数据文件.它指向默认的安装数据文件,我希望它指向/var/mysql
中的现有数据文件.这是/etc/my.cnf
Update: I've STOPPED the older mysql process which was running and causing some confusion. Now I think I have only the newer (5.1.40) version running. BUT, it's pointing to the wrong data file. It's pointing to a default install data file and I'd like it to point to the existing data file in /var/mysql
. Here's a portion of /etc/my.cnf
# The following options will be passed to all MySQL clients
[client]
#password = your_password
port = 3306
socket = /var/mysql/mysql.sock
# Here follows entries for some specific programs
# The MySQL server
[mysqld]
port = 3306
socket = /var/mysql/mysql.sock
这指向较旧的mysql.sock.我似乎在较新的MySQL安装目录树中找不到?!?除非它晦涩难懂.
this is pointing to the older mysql.sock. I can't seem to find in the directory tree of the newer MySQL install?!? unless it's somewhere obscure.
有人帮忙吗?基本上,我安装了更新的MySQL,现在需要获取此新版本以使用现有数据启动.并整理出mysql.sock这个东西....
Anyone help? Basically I installed a newer MySQL and now need to get this new version to launch with my existing data. And sort out this mysql.sock thing....
我最近在Mac OS X Server上更新了MySQL,现在很难通过Rails应用程序连接到它.或始终在命令行中解决此问题.
I've recently updated MySQL on Mac OS X Server and am having a hell of a time connecting to it from a rails app. or consistently from the command-line for that matter.
我确定这是我的明显错误,但是我只有中等的命令行经验,因此希望有人可以提供帮助...
i'm sure this is an obvious error on my part but I only have moderate command-line experience so hoping someone can help...
还相关的是我的Rails应用程序不再可以连接.未能通过/tmp/mysql.sock
连接,但是我不确定为什么它会在那里,因为/tmp中没有mysql.sock,而且我不知道它应该在什么位置.
also related is my rails app no longer can connect. Failing to connect via /tmp/mysql.sock
but I'm not sure why it's looking there because there is no mysql.sock in /tmp and I don't know what/where it should be....
编辑:从mysql_config --sockets添加结果
adding results from mysql_config --sockets
$ mysql_config --sockets
Usage: /usr/local/mysql/bin/mysql_config [OPTIONS]
Options:
--cflags [-I/usr/local/mysql/include -g -Os -arch ppc -fno-common -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL]
--include [-I/usr/local/mysql/include]
--libs [-arch ppc -L/usr/local/mysql/lib -lmysqlclient -lz -lm -lmygcc]
--libs_r [-arch ppc -L/usr/local/mysql/lib -lmysqlclient_r -lz -lm -lmygcc]
--plugindir [/usr/local/mysql/lib/plugin]
--socket [/tmp/mysql.sock]
--port [0]
--version [5.1.40]
--libmysqld-libs [-arch ppc -L/usr/local/mysql/lib -lmysqld -ldl -lz -lm -lmygcc]
Edit2 ,其中mysql_config
Edit2 which mysql_config
$ which mysql_config
/usr/local/mysql/bin/mysql_config
推荐答案
您正在尝试对服务器和客户端使用不同的套接字.您的Rails尝试连接到/tmp/mysql.sock,而MySQL正在/var/mysql/mysql.sock上监听.
You are trying to use different sockets for the server and client. Your Rails is trying to connect to /tmp/mysql.sock, by MySQL is listening on /var/mysql/mysql.sock.
通常,MySQL配置存储在/etc/my.cnf中,但是在您的ps
输出中,我看到套接字路径是作为参数给出的.因此,这实际上取决于您系统的具体情况.
Normally MySQL configuration is stored in /etc/my.cnf, but in your ps
your output I see socket path is given as a parameter. So really depends on your system's specifics.
无论如何,请查看/etc/my.cnf和您的database.yml,并确保mysql.sock出现在两个文件的相同路径中.
Anyway, look in /etc/my.cnf and your database.yml and make sure mysql.sock appears at the same path in both files.
这篇关于MySQL地狱...无法连接到数据库/tmp/mysql.sock的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!