在 Snow Leopard 上启动 MySQL 错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3126173/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 16:25:30  来源:igfitidea点击:

Starting MySQL Error on Snow Leopard

mysqlsqlmacososx-snow-leopard

提问by Hristo

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.

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

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.

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

Any ideas?

有任何想法吗?

UPDATE

更新

This is my /etc/my.cnffile.

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

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

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

UPDATE 2

更新 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.cnfexists in /etc/, things don't work. The MySQL verion is:

在设置 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

更新 3

mysql.err:

mysql.错误:

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:

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

采纳答案by Unreason

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

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

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 thiswill help)

尝试使用一个常用的 my.cnf 文件或在 [mysqld] 部分下为用户、pid-file、port、basedir、datadir、tmpdir 添加选项(这是 linux 机器上基本 mysqld 设置的引用,对于 OS X 可能是这个会有所帮助)

[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

回答by Jed Schneider

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

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

Then from terminal

然后从终端

brew install mysql

brew install mysql

and follow the short list of directions that follow the installation

并遵循安装后的简短说明列表

to see the instructions again

再次查看说明

brew info mysql

brew info mysql

回答by ryan

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

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

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

Homebrew 安装 mysql、snow leopard(最近更新)

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

确保您/usr/local/var/mysql和所有子目录归当前用户所有!

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

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

如果您想使用 启动 mysql/etc/my.cnf并且您正在指定类似的东西

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.

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

回答by Aaron Harun

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

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

On linux the command would be:

在 linux 上,命令是:

sudo touch /tmp/mysqld.sock

sudo touch /tmp/mysqld.sock

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

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

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

我假设 Mac 上的命令行是一样的。

回答by carpeliam

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 foundissue), but my root cause was a little different.

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

I had a working /etc/my.cnffile 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.

我有一个工作/etc/my.cnf文件突然停止工作,所以我确信问题不是我的配置。结果发现下的一个子目录/usr/local/var/mysql/归 _mysql:staff 所有,而它本应归我所有。跑步后chown -R 'whoami' /usr/local/var/mysql/,世界一切都好。

回答by Anurag

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

首先,你必须解锁那个pid进程。stop mysql bysrvice mysql stop之后输入这个命令ps-ef| grep mysql它会显示两个sql的pid。杀死两者 kill -9 pid 1 pid2然后启动 sql by service mysql start

回答by Piskvor left the building

There seems to be an error message:

似乎有一条错误信息:

line 418: pidof: command not found

Do you have pidofinstalled? Its manpagesays:

pidof安装了吗?它的联机帮助页说:

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

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

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

也许符号链接不存在或者你的 Mac OS 上没有安装 killall5?

回答by sarnold

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

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

Quoting David Tonhofer:

引用 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.
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. :)

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

回答by Matt Bannert

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:

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

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

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

and restarting does help often.

重新启动确实经常有帮助。

HTH

HTH

回答by Scott Schulthess

If you installed view homebrew, try

如果您安装了查看自制软件,请尝试

unset TMPDIR
mysql_install_db