mysql.server 启动时出现 PID 错误?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4444861/
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 18:00:20  来源:igfitidea点击:

PID error on mysql.server start?

mysqlmacospidhomebrew

提问by joecritch

I've just tried installing MySQL using homebrew (on Mac OS X 10.6), but I've run across an issue at the first hurdle. When trying to manually start the server (mysql.server start), I get the following error:

我刚刚尝试使用自制软件(在 Mac OS X 10.6 上)安装 MySQL,但我在第一个障碍中遇到了一个问题。尝试手动启动服务器(mysql.server start)时,出现以下错误:

. ERROR! Manager of pid-file quit without updating file.

Unfortunately I'm not sure of which error logs or configuration files to check, as I've never installed MySQL in this way before.

不幸的是,我不确定要检查哪些错误日志或配置文件,因为我以前从未以这种方式安装过 MySQL。

采纳答案by Mike Hornblade

I ran into this same problem when installing via homebrew. Make sure you run these commands (which are listed during install but easy to miss):

我在通过自制软件安装时遇到了同样的问题。确保您运行这些命令(在安装过程中列出但很容易错过):

unset TMPDIR
mysql_install_db

回答by Lee

you probably need to ensure that you're running mysql as the rootuser -- otherwise it won't have permission to write the PID file (thus the error you're receiving).

您可能需要确保以root用户身份运行 mysql - 否则它将无权写入 PID 文件(因此您会收到错误)。

Try this:

尝试这个:

sudo mysql.server start

you'll be prompted for your password. (this assumes that your user account has permissions to "sudo" -- which it should, unless it's setup as a restricted user account in OS X).

系统会提示您输入密码。(这假设您的用户帐户具有“sudo”权限——它应该如此,除非它在 ​​OS X 中设置为受限用户帐户)。

This may not be the only issue -- but it should get you to the next step anyway.

这可能不是唯一的问题——但无论如何它应该让你进入下一步。

good luck!

祝你好运!

回答by lmmendes

I ran into the same issue while trying to install MySQL 5.5.15 in Lion using homebrew and resolved the issue with:

我在尝试使用自制软件在 Lion 中安装 MySQL 5.5.15 时遇到了同样的问题,并通过以下方式解决了该问题:

mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp

and creating a the file ~/my.cnf

并创建文件 ~/my.cnf

with the content:

内容:

 [mysqld]
   basedir=/usr/local/Cellar/mysql/5.5.15
   datadir=/usr/local/var/mysql

basedir - should be your current MySQL instalation dir datadir - should be the location of MySQL data

basedir - 应该是你当前的 MySQL 安装目录 datadir - 应该是 MySQL 数据的位置

You can figure out that too location by watching the make command during the "brew install mysql" searching for something like this:

您可以通过在“brew install mysql”期间观察 make 命令来找出类似的位置:

-DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/mysql/5.5.15 -DMYSQL_DATADIR=/usr/local/var/mysql -DINSTALL_MANDIR=/usr/local/Cellar/mysql

Where DCMAKE_INSTALL_PREFIX = basedir and DMYSQL_DATADIR = datadir

其中 DCMAKE_INSTALL_PREFIX = basedir 和 DMYSQL_DATADIR = datadir

回答by Jaspreet Singh Lidder

These following two commands should solve your issue.

以下两个命令应该可以解决您的问题。

> unset TMPDIR
> mysql_install_db --verbose --user=\`whoami\` --basedir="$(brew
--prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp

回答by Grozz

Nothing else really helped, but the following worked:

没有其他真正的帮助,但以下工作有效:

$ ps aux | grep mysql
tagir           27260   0.0  1.0  3562356 175120   ??  S     2:52PM   0:00.42 mysqld --skip-grant-tables
tagir           42704   0.0  0.0  2434840    784 s000  S+    3:04PM   0:00.00 grep mysql
$ kill 27260
# Careful! This might erase your existing data
$ rm -rf /usr/local/var/mysql
$ mysqld --initialize
$ mysql.server start

回答by rmcsharry

I am adding this here because I encountered this problem several times after installing other software. MySQL was working fine for days, then suddenly I get this error.

我在这里添加这个是因为我在安装其他软件后多次遇到这个问题。MySQL 工作了好几天,然后突然我收到这个错误。

It seems to happen when I install something (eg. elasticsearch or Puma web server). The MySql permissions get reverted again (back to me, and not _mysql). No idea why.

当我安装某些东西(例如,elasticsearch 或 Puma Web 服务器)时,似乎会发生这种情况。MySql 权限再次恢复(返回给我,而不是_mysql)。不知道为什么。

  • MacOS Sierra
  • Homebrew 1.0.5-43-g41b2df8 (2016-10-02)
  • MySQL 5.7.15
  • MacOS 塞拉利昂
  • 自制 1.0.5-43-g41b2df8 (2016-10-02)
  • MySQL 5.7.15

So I have found that one cause of this is the permissions on the location where MySQL stores your databases, which by default is here:

所以我发现造成这种情况的一个原因是 MySQL 存储数据库的位置的权限,默认情况下,这里是:

/usr/local/var/mysql

If you look in that folder you will see a file

如果您查看该文件夹,您将看到一个文件

<your computer name>.err

If you look inside that file (moreit or catit) you will probably see this error:

如果您查看该文件(more它或cat它),您可能会看到以下错误:

[ERROR] InnoDB: The innodb_system data file 'ibdata1' must be writable

If so then you know it is a permissions issue.

如果是这样,那么您就知道这是一个权限问题。

If you don't care, you can probably just run MySQL by just running mysqld(and leave that terminal open).

如果您不在乎,您可能可以通过运行mysqld(并保持该终端打开)来运行 MySQL 。

If you do care:

如果你真的关心:

ls -al /usr/local/var/mysql

ls -al /usr/local/var/mysql

you will notice that the permissions are probably all set to you (your user account). This means mysql cannot mount your databases when you run it using the homebrew shortcut sudo mysql.server start[even though you are using sudo to run in 'admin' mode].

您会注意到权限可能都设置给您(您的用户帐户)。这意味着当您使用自制软件快捷方式运行 mysql 时,它无法挂载您的数据库sudo mysql.server start[即使您使用 sudo 在“管理员”模式下运行]。

So, change the permissions:

因此,更改权限:

$ sudo chown -R _mysql /usr/local/var/mysql
$ sudo chmod -R o+rwx /usr/local/var/mysql

Then it will work.

然后它会起作用。

回答by Paul Fox

It appears that for whatever reason I can't comment below Immendes above, but on 10.8.2 with mySQL 5.6.10, in addition to verifying the db_install and adding the my.cnf, I also had to chown -R myusername /tmp/mysql.sock.

看来无论出于何种原因我都无法在上面的 Immendes 下方发表评论,但是在 10.8.2 和 mySQL 5.6.10 上,除了验证 db_install 并添加 my.cnf 之外,我还必须 chown -R myusername /tmp/ mysql.sock。

It appears that allowing mySQL to run under the user (as apposed to root or www as I woudl do on linux) is not the best idea in this regard (though Homebrew could update the formula -- beyond my scope and time).

似乎允许 mySQL 在用户下运行(就像我在 linux 上所做的那样与 root 或 www 相关)在这方面并不是最好的主意(尽管 Homebrew 可以更新公式 - 超出了我的范围和时间)。