无法在 mac OS X 上启动 mysql,出现 mysql.sock 连接错误

发布于 2024-08-09 17:01:39 字数 1299 浏览 3 评论 0原文

我正在尝试让 mysql 在我的 mac 上运行。我使用 macports 进行初始安装,但无法解决此 mysql 套接字错误。 注意:如果命令在下面看起来很奇怪,macports 会将版本号附加到命令中。

错误:

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

我在以下情况下收到此错误:

mysqladmin5 -u root 密码
还有
mysql5 -u root -p

我的安装和启动过程
使用 macports 安装 mysql:

sudo port install mysql5 +server
sudo /opt/local/lib/mysql5/bin/mysql_install_db --user=mysql

像这样启动:

sudo /opt/local/bin/mysqld_safe5

也尝试过:

sudo /opt/local/share/mysql5/mysql/mysql.server start

我如何尝试解决这个问题
我尝试添加到 my.cnf 文件

[mysqld_safe]套接字=/tmp/mysql.sock

唯一的问题是没有 my.cnf 文件开始,所以我不确定我是否在正确的位置创建了它。

我还打算将 mysql.sock 文件模拟链接到 /tmp 目录,但系统上的任何位置都没有 mysql.sock 文件。

所以我创建了一个 mysql.sock 文件

触摸/tmp/mysql.sock
但这也不起作用。

我想也许我在安装过程中错过了一些东西,因为我在系统上找不到 my.cnf 或 mysql.sock 文件。

这是我使用的指南:
http://2tbsp.com/content/install_and_configure_mysql_5_macports

I'm trying to get mysql running on my mac. I used macports for the initial install but can't get past this mysql socket error.
Note: macports appends the version number to commands if they look odd below.

Error:

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

I get this error when:

mysqladmin5 -u root password
and also
mysql5 -u root -p

My install and start process
Installed mysql with macports:

sudo port install mysql5 +server
sudo /opt/local/lib/mysql5/bin/mysql_install_db --user=mysql

Started like this:

sudo /opt/local/bin/mysqld_safe5

Also tried:

sudo /opt/local/share/mysql5/mysql/mysql.server start

How I've tried to solve this
I tried adding to the my.cnf file

[mysqld_safe] socket = /tmp/mysql.sock

Only problem is there wasn't a my.cnf file to begin with so I'm not sure if I created it in the right place.

I was also going to sim link the mysql.sock file to the /tmp dir but there's no mysql.sock file anywhere on the system.

So I created a mysql.sock file

touch /tmp/mysql.sock
But this didn't work either.

I'm thinking maybe I missed something in the install process since I can't find the my.cnf or mysql.sock file on the system.

Here's the guide I used:
http://2tbsp.com/content/install_and_configure_mysql_5_macports

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

伪装你 2024-08-16 17:01:40

Mac 搬到了 mysql.sock 所在的位置。我认为一部分希望位于 /var/mysql 中,而其他部分希望它位于 /tmp 中。所以,我做了一个符号链接......

Mac moved where mysql.sock lives. I think one part want sit to be in /var/mysql, and something else wants it to be in /tmp. So, I made a symlink...

箹锭⒈辈孓 2024-08-16 17:01:40

mysqld 是否正在运行(ps ax)?如果它没有运行,请通过日志找出它没有运行的原因。我不熟悉它的 macports 安装,所以我不能告诉你。

顺便说一句,为了在我的 Mac 上进行开发,我只需获取官方 mysql 软件包,它附带一个系统首选项窗格来为您启动 mysql。总的来说,我发现 fink/macports 带来的麻烦比它们的价值要多。

Is mysqld even running (ps ax)? If it's not running, figure out why it's not running with the logs. I'm not familiar with the macports install of it, so I can't tell you.

As an aside, for development on my Mac I just grab the official mysql packages, which comes with a system prefs pane to start mysql for you. I've found fink/macports more trouble than they're worth, in general.

小ぇ时光︴ 2024-08-16 17:01:40

mysql.sock 由服务器进程动态创建,并在退出后删除。提前创建它或符号链接将不起作用。

您需要弄清楚在哪里正确配置它。显然,这是在 /opt/local/etc/mysql5/my.cnf 中完成的

mysql.sock is created on the fly by the server process and removed once it exits. Creating it beforehand or symlinking won't work.

You'll need to figure out where to properly configure it. Apparently, this is done in /opt/local/etc/mysql5/my.cnf

冷默言语 2024-08-16 17:01:40

我花了很多时间试图让mysql运行起来。我认为这是您问题的部分答案。执行 sudo port install mysql5-server。我今天刚刚这样做,它解决了我刚刚执行 sudo port install mysql5 时遇到的很多问题。互联网上的大多数提示都是关于 mysql5-server 而不是 mysql5;一旦我安装了 mysql5-server,你使用的指南就与我一起工作了。不要忘记删除之前安装中创建的文件夹/文件并执行 sudo port uninstall mysql5。这个问题大约两个月前被问到;希望这能让你重回正轨。

I spent a lot of time trying to get mysql running. Here, I think is part of the answer to your problem. Do a sudo port install mysql5-server. I just did that today and it fixed a lot of the problems I had when I just did sudo port install mysql5. Most of the hints on the interwebs are about mysql5-server not mysql5; the guide you used worked with me once I installed mysql5-server. Don't forget to delete the folders/files created from your previous install and do a sudo port uninstall mysql5. This question was asked about two months ago; hopefully this will put you back on track.

听风念你 2024-08-16 17:01:40

我在这里发布了我的解决方案:
http://djcode.posterous.com/installing- mysql-on-mac-os-x-snow-leopard

感谢您的帮助!

I posted my solution here:
http://djcode.posterous.com/installing-mysql-on-mac-os-x-snow-leopard

Thanks for the help!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文