在 Snow Leopard 上启动 MySQL 时出错

发布于 2024-09-07 00:31:19 字数 3109 浏览 3 评论 0原文

原始帖子

我刚刚删除并重新安装了 Snow Leopard。我安装了 MySQL 5.1.48 64 位干净的。我的 MySQL 服务器出现问题...当我启动计算机并登录时,服务器没有运行。我尝试通过单击“启动 MySQL 服务器”使用首选项窗格来启动它,但它所做的只是突出显示蓝色按钮并思考一分钟,然后按钮恢复正常,什么也没有发生。

然后我尝试从终端启动它:

Hristo$ sudo /usr/local/mysql/support-files/mysql.server start
Starting MySQL
.....................................................................
ERROR! Manager of pid-file quit without updating file.

所以我检查了状态:

Hristo$ sudo /usr/local/mysql/support-files/mysql.server status
Password:
/usr/local/mysql/support-files/mysql.server: line 418: pidof: command not found
 ERROR! MySQL is not running

我尝试了这个:

Hristo$ /usr/local/mysql/bin/mysql -u root -p
Enter password: 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

所以我不知道该怎么做。当我第一次安装时,服务器正在工作,但我进入首选项窗格尝试停止它......并且发生了同样的事情......我单击“停止 MySQL Server”按钮,它做了一些思考,然后什么也没做。所以我重新启动了计算机,现在我遇到了上述问题,显然 mysql.sock 文件不再位于 /tmp/ 中。我安装的时候有,重启电脑后就没有了。

有什么想法吗?

更新

这是我的/etc/my.cnf 文件。

[client]
socket = /var/mysql/mysql.sock

[mysqld]
socket = /var/mysql/mysql.sock

更新2

在设置 Apache、PHP 和 MySQL 时,我遵循了以下说明:http://superfancy.net/coding/php-mysql-apache-in-mac-osx-leopard/ 现在,如果我删除 MySQL 配置文件,事情似乎工作正常。但是当 my.cnf 存在于 /etc/ 中时,事情就不起作用了。 MySQL 版本是:

Hristo$ mysql --version
/usr/local/mysql/bin/mysql  Ver 14.14 Distrib 5.1.46, for apple-darwin9.8.0 (i386) using readline 5.1

UPDATE 3

mysql.err:

100706 11:38:36 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
100706 11:38:36 [Warning] '--log' is deprecated and will be removed in a future release. Please use ''--general_log'/'--general_log_file'' instead.
100706 11:38:36 [Warning] '--log_slow_queries' is deprecated and will be removed in a future release. Please use ''--slow_query_log'/'--slow_query_log_file'' instead.
100706 11:38:36 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/mysql/data/ is case insensitive
100706 11:38:36 [Note] Plugin 'FEDERATED' is disabled.
100706 11:38:36  InnoDB: Started; log sequence number 0 69987
100706 11:38:36 [ERROR] Can't start server : Bind on unix socket: Permission denied
100706 11:38:36 [ERROR] Do you already have another mysqld server running on socket: /var/mysql/mysql.sock ?
100706 11:38:36 [ERROR] Aborting

100706 11:38:36  InnoDB: Starting shutdown...
100706 11:38:41  InnoDB: Shutdown completed; log sequence number 0 69987
100706 11:38:41 [Note] /usr/local/mysql/bin/mysqld: Shutdown complete

mysql.log:

/usr/local/mysql/bin/mysqld, Version: 5.1.46-log (MySQL Community Server (GPL)). started with:
Tcp port: 0  Unix socket: /var/mysql/mysql.sock
Time                 Id Command    Argument

ORIGINAL POST

I just erased and re-installed Snow Leopard. I installed MySQL 5.1.48 64-bit clean. I'm having issues with the MySQL server... when I boot the computer and log in, the server is not running. I tried to start it using the preference pane by clicking "Start MySQL Server", but all it did was highlight the button blue and think for like a minute, and then the button went back to normal and nothing happened.

I then tried starting it from the terminal:

Hristo$ sudo /usr/local/mysql/support-files/mysql.server start
Starting MySQL
.....................................................................
ERROR! Manager of pid-file quit without updating file.

so I checked the status:

Hristo$ sudo /usr/local/mysql/support-files/mysql.server status
Password:
/usr/local/mysql/support-files/mysql.server: line 418: pidof: command not found
 ERROR! MySQL is not running

I tried this:

Hristo$ /usr/local/mysql/bin/mysql -u root -p
Enter password: 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

So I'm not sure what to do. When I first installed, the server was working but I went to the preference pane to try and stop it… and the same thing happened… I clicked the "Stop MysQL Server" button, it did some thinking, then nothing. So I restarted the computer and now I'm having the above problems and apparently, the mysql.sock file is not in /tmp/ anymore. It was there when I installed, and it is not there after I restarted the computer.

Any ideas?

UPDATE

This is my /etc/my.cnf file.

[client]
socket = /var/mysql/mysql.sock

[mysqld]
socket = /var/mysql/mysql.sock

UPDATE 2

When setting up Apache, PHP, and MySQL, I followed these instructions: http://superfancy.net/coding/php-mysql-apache-in-mac-osx-leopard/ Right now, if I remove the MySQL configuration file, things seem to work fine. But when my.cnf exists in /etc/, things don't work. The MySQL verion is:

Hristo$ mysql --version
/usr/local/mysql/bin/mysql  Ver 14.14 Distrib 5.1.46, for apple-darwin9.8.0 (i386) using readline 5.1

UPDATE 3

mysql.err:

100706 11:38:36 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
100706 11:38:36 [Warning] '--log' is deprecated and will be removed in a future release. Please use ''--general_log'/'--general_log_file'' instead.
100706 11:38:36 [Warning] '--log_slow_queries' is deprecated and will be removed in a future release. Please use ''--slow_query_log'/'--slow_query_log_file'' instead.
100706 11:38:36 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/mysql/data/ is case insensitive
100706 11:38:36 [Note] Plugin 'FEDERATED' is disabled.
100706 11:38:36  InnoDB: Started; log sequence number 0 69987
100706 11:38:36 [ERROR] Can't start server : Bind on unix socket: Permission denied
100706 11:38:36 [ERROR] Do you already have another mysqld server running on socket: /var/mysql/mysql.sock ?
100706 11:38:36 [ERROR] Aborting

100706 11:38:36  InnoDB: Starting shutdown...
100706 11:38:41  InnoDB: Shutdown completed; log sequence number 0 69987
100706 11:38:41 [Note] /usr/local/mysql/bin/mysqld: Shutdown complete

mysql.log:

/usr/local/mysql/bin/mysqld, Version: 5.1.46-log (MySQL Community Server (GPL)). started with:
Tcp port: 0  Unix socket: /var/mysql/mysql.sock
Time                 Id Command    Argument

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

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

发布评论

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

评论(10

迟到的我 2024-09-14 00:31:19

使用快速安装方法安装 homebrew 包管理器
http://github.com/mxcl/homebrew

然后从终端

brew install mysql

并按照安装后的简短说明列表

再次查看说明

brew info mysql

Install homebrew package manager with the quick install method
http://github.com/mxcl/homebrew

Then from terminal

brew install mysql

and follow the short list of directions that follow the installation

to see the instructions again

brew info mysql

追风人 2024-09-14 00:31:19

我认为您的 my.cnf 文件中的某个地方有错误。

尝试获取库存 my.cnf 文件之一,或在 [mysqld] 部分下添加用户、pid 文件、端口、basedir、datadir、tmpdir 选项(这里是 linux 机器上基本 mysqld 设置的引用,对于 OS X 可能< a href="http://www.drupalcoder.com/blog/create-mysql-configuration-file-mycnf-on-mamp.html" rel="nofollow noreferrer">这会有所帮助)

[mysqld]
#
# * Basic Settings
#

user        = mysql
pid-file    = /var/run/mysqld/mysqld.pid
socket      = /var/run/mysqld/mysqld.sock
port        = 3306
basedir     = /usr
datadir     = /var/lib/mysql
tmpdir      = /tmp
skip-external-locking

#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address        = 127.0.0.1

I think there is an error somewhere in your my.cnf file.

Try to take one of the stock my.cnf files or add options for user, pid-file, port, basedir, datadir, tmpdir under [mysqld] section (here's a quote of basic mysqld settings on linux machine, for OS X maybe this will help)

[mysqld]
#
# * Basic Settings
#

user        = mysql
pid-file    = /var/run/mysqld/mysqld.pid
socket      = /var/run/mysqld/mysqld.sock
port        = 3306
basedir     = /usr
datadir     = /var/lib/mysql
tmpdir      = /tmp
skip-external-locking

#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address        = 127.0.0.1
紫轩蝶泪 2024-09-14 00:31:19

以防万一其他人遇到这个令人恼火的问题......

mysql、snow leopard 的自制安装(最新更新)

确保您的 /usr/local/var/mysql 和所有子目录都是拥有的由当前用户!

sudo chown -R <user> /usr/local/var/mysql

如果你想使用 /etc/my.cnf 启动 mysql 并且你指定了类似

default-character-set=utf8

你的服务器永远不会启动的内容。我相信MySql 5.5.x默认有这个设置。在 my.cnf 文件中注释掉这一行并
mysql.server start 应该可以解决问题。

Just in case anyone else runs into this infuriating issue.....

Homebrew install of mysql, snow leopard (most recent update)

make sure your /usr/local/var/mysql and all subdirs is owned by current user!

sudo chown -R <user> /usr/local/var/mysql

if you want to startup mysql using the /etc/my.cnf and you are specifying something like

default-character-set=utf8

your server will never start. I believe MySql 5.5.x has this set by default. Comment this line out in your my.cnf file and
mysql.server start should do the trick.

一杯敬自由 2024-09-14 00:31:19

每次加载 MySQL 时都应该重新创建该文件,但有时权限会妨碍。尝试手动创建 /tmp/mysqld.sock

在 Linux 上,命令为:

sudo touch /tmp/mysqld.sock

然后设置正确的所有者:
sudo chown mysql:mysql /tmp/mysqld.sock

我认为 Mac 上的命令行是相同的。

The file is supposed to be recreated every time that MySQL is loaded, but sometimes permissions will get in the way. Try manually creating /tmp/mysql.sock

On linux the command would be:

sudo touch /tmp/mysqld.sock

Then set the correct owner:
sudo chown mysql:mysql /tmp/mysqld.sock

I assume command line on a mac would be the same.

情场扛把子 2024-09-14 00:31:19

我想其中一些其他解决方案将适合其他一些人,但我有所有这些相同的症状(包括 line 418: pidof: command not found 问题),但我的根本原因是有点不同。

我有一个正在工作的 /etc/my.cnf 文件突然停止工作,所以我确信问题不是我的配置。原来,/usr/local/var/mysql/ 下的一个子目录属于_mysql:staff,而它本应属于我。运行 chown -R 'whoami' /usr/local/var/mysql/ 后,一切正常。

I imagine that some of these other solutions will be appropriate for some other people, but I had all of these same symptoms (including the line 418: pidof: command not found issue), but my root cause was a little different.

I had a working /etc/my.cnf file that abruptly stopped working, so I was confident the problem was not my config. It turned out that a subdirectory under /usr/local/var/mysql/ was owned by _mysql:staff, when it should have been owned by me. After running chown -R 'whoami' /usr/local/var/mysql/, all was right with the world.

神爱温柔 2024-09-14 00:31:19

首先你必须解锁那个 pid 进程。通过 srvice mysql stop 停止 mysql
之后输入此命令 ps-ef| grep mysql 它将显示sql的两个pid。杀死两者
kill -9 pid 1 pid2 然后通过service mysql start启动sql。

First of all you have to unlock that pid process then. stop mysql by srvice mysql stop
After that type this command ps-ef| grep mysql It will show two pid of sql. kill both by
kill -9 pid 1 pid2 then start sql by service mysql start.

筱武穆 2024-09-14 00:31:19

似乎有一条错误消息:

line 418: pidof: command not found

Do you have pidofinstalled? 其手册页说:

pidof 只是一个指向killall5 程序的(符号)链接,该程序也应该位于/sbin

也许该符号链接不存在或者您的Mac 操作系统上未安装killall5?

There seems to be an error message:

line 418: pidof: command not found

Do you have pidof installed? Its manpage says:

pidof is simply a (symbolic) link to the killall5 program, which should also be located in /sbin

Perhaps the symlink doesn't exist or killall5 is not installed on your Mac OS?

与他有关 2024-09-14 00:31:19

http://dev.mysql.com/doc/refman/ 5.5/en/mysql-server.html

引用 David Tonhofer:

并且还添加
------------
echo "管理器 PID 文件是 $pid_file, 服务器 PID 文件是 $server_pid_file"
------------
直接在 'case "$mode" in' 行之前
为了一些伟大的调试正义。

我最初的猜测是 mysqld 无权更新/删除其 pidfile,并且可能有一个剩余的 pidfile 需要手动删除。但“伟大的调试正义”听起来太好了,不容错过。 :)

http://dev.mysql.com/doc/refman/5.5/en/mysql-server.html

Quoting David Tonhofer:

And also add
-----------
echo "Manager PID file is $pid_file, Server PID file is $server_pid_file"
-----------
directly before the line 'case "$mode" in'
for some great debugging justice.

My initial guess was that the mysqld doesn't have permission to update / delete its pidfile, and probably there is a left-over pidfile that needs to be removed by hand. But "great debugging justice" sounds too good to miss. :)

oО清风挽发oО 2024-09-14 00:31:19

尝试将其作为 MAMP 的一部分安装。这将在不同的位置安装 mysql 服务器(Applications/MAMP/mysql 以及 apache 等)。然后您可以使用小部件来启动它。您还可以使用活动监视器(应用程序/实用程序)来监视活动。此外:

删除:/Applications/MAMP/tmp/mysql/mysql.pid

并重新启动通常会有所帮助

Try to install it as a part of MAMP . That will install a mysql server in a different location ( Applications/MAMP/mysql along with apache etc. Then you can just use the widget to start it. You can also monitor the activity with the acitivity monitor (Applications/utilities) . Besides:

Deleting: /Applications/MAMP/tmp/mysql/mysql.pid

and restarting does help often.

HTH

‘画卷フ 2024-09-14 00:31:19

如果您安装了 view homebrew,请尝试

unset TMPDIR
mysql_install_db

If you installed view homebrew, try

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