MySql 服务器启动错误“服务器退出而不更新 PID 文件”

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

MySql server startup error 'The server quit without updating PID file '

mysql

提问by Chinmay

On Snow Leopard, starting MySQL gives the following error:

在 Snow Leopard 上,启动 MySQL 会出现以下错误:

The server quit without updating PID file

服务器退出而不更新PID文件

my.cnf

我的.cnf

[mysqld]
port            = 3306

socket          = /tmp/mysql.sock

skip-external-locking

key_buffer_size = 16K

pid-file=/var/run/mysqld/mysqld.pid

[mysqld_safe]

log-error=/var/log/mysqld.log

pid-file=/var/run/mysqld/mysqld.pid

回答by Tombart

try to find your log file with suffix ".err", there should be more info. It might be in:

尝试找到后缀为“.err”的日志文件,应该有更多信息。它可能在:

/usr/local/var/mysql/your_computer_name.local.err

/usr/local/var/mysql/your_computer_name.local.err

It's probably problem with permissions

应该是权限问题

  1. check if any mysql instance is running

    ps -ef | grep mysql

    if yes, you should stop it, or kill the process

    kill -9 PID

    where PIDis the number displayed next to username on output of previous command

  2. check ownership of /usr/local/var/mysql/

    ls -laF /usr/local/var/mysql/

    if it is owner by rootyou should change it mysqlor your_user

    sudo chown -R mysql /usr/local/var/mysql/

  1. 检查是否有任何 mysql 实例正在运行

    ps -ef | mysql

    如果是,你应该停止它,或者终止进程

    杀死 -9 PID

    PID上一个命令的输出中用户名旁边显示的数字在哪里

  2. 检查所有权 /usr/local/var/mysql/

    ls -laF /usr/local/var/mysql/

    如果它是root您的所有者,则应更改它mysqlyour_user

    须藤 chown -R mysql /usr/local/var/mysql/

回答by svs

Did you follow the instructions from brew install mysql?

您是否按照 的说明进行操作brew install mysql

Set up databases to run AS YOUR USER ACCOUNT with:

设置数据库以作为您的用户帐户运行:

For mysql 5.x:

对于 mysql 5.x:

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

To set up base tables in another folder, or use a different user to run mysqld, view the help for mysqld_install_db:

要在另一个文件夹中设置基表,或使用不同的用户运行 mysqld,请查看以下帮助mysqld_install_db

mysql_install_db --help

and view the MySQL documentation:

并查看 MySQL 文档:

For mysql 8.x:

对于 mysql 8.x:

unset TMPDIR
mysqld --initialize-insecure --log-error-verbosity --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp

Make sure the data directory /usr/local/var/mysqlabove is empty, backup it if necessary.

确保/usr/local/var/mysql上面的数据目录为空,必要时备份。

To run as, for instance, user "mysql", you may need to sudo:

例如,要以用户“mysql”的身份运行,您可能需要sudo

sudo mysql_install_db ...options...

Start mysqld manually with:

使用以下命令手动启动 mysqld:

mysql.server start

Note: if this fails, you probably forgot to run the first two steps up above

注意:如果失败,您可能忘记运行上面的前两个步骤

回答by ukliviu

I had the same issue on my Mac machine (correctly followed all the installation steps suggested by brew install).

我在我的 Mac 机器上遇到了同样的问题(正确遵循 建议的所有安装步骤brew install)。

Deleting the error file fixed it for me:

删除错误文件为我修复了它:

sudo rm -rf /usr/local/var/mysql/dev.work.err(dev.workis my hostname)

sudo rm -rf /usr/local/var/mysql/dev.work.errdev.work是我的主机名)

This worked because dev.work.errwas owned by _mysql:wheelinstead of my own username. CHOWN-ing the error file would have probably fixed it as well.

这是有效的,因为它dev.work.err是由_mysql:wheel我自己的用户名而不是拥有的。CHOWN-ing 错误文件可能也会修复它。

回答by Sam Ruberti

After rebooting I had the same issue. Here is how I fixed it:

重新启动后,我遇到了同样的问题。这是我修复它的方法:

 sudo chown -R _mysql /usr/local/var/mysql

回答by mikoop

This worked for me...

这对我有用...

Check all of the MySQL processes running:

检查所有正在运行的 MySQL 进程:

$ ps aux | grep mysql

USER     PID    %CPU  %MEM 
_mysql   5970   0.0   0.4 ...

Then kill all the processes listed from the above command using the following:

然后使用以下命令终止上述命令中列出的所有进程:

$ sudo kill -9 [PID]

Replace [PID]with the individual PID from the list above, e.g. 5970.

替换[PID]为上面列表中的单个 PID,例如5970.

Do that for all of the lines you see with the first command.

对您使用第一个命令看到的所有行执行此操作。

Then you can startup your MySQL server again:

然后你可以再次启动你的 MySQL 服务器:

mysql.server start

回答by cosbor11

This error can occur when trying to start msql after it was improperly shutdown.

在不正确关闭后尝试启动 msql 时可能会发生此错误。

  1. Take a look at the mysql error log file. If it mentions something like "Check that you do not already have another mysqld process using the same data or log files.", then you need to properly shutdown that process.

  2. See what process mysql is running on, use this command: lsof -i:3306

  1. 查看mysql错误日志文件。如果它提到诸如“检查您是否已经有另一个使用相同数据或日志文件的 mysqld 进程”之类的内容。,那么您需要正确关闭该进程。

  2. 查看mysql正在运行的进程,使用以下命令: lsof -i:3306

Your output should look like this:

您的输出应如下所示:

COMMAND  PID    USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
mysqld  4249 username   17u  IPv4 0x7843d9d130469c0b      0t0  TCP localhost:mysql (LISTEN)
  1. Terminate the process running mysql: kill -15 4249
  1. 终止运行mysql的进程: kill -15 4249

Kill -15 sends a siganl to the process to free up any resources it is locking and terminate the process after.

Kill -15 向进程发送一个信号以释放它锁定的所有资源并在之后终止进程。

  1. Now mysql should startup with no problems: mysql.server start
  1. 现在 mysql 应该可以正常启动了: mysql.server start

回答by jaredsmith

My error file told me also that the port may be being used by another process, but simply running sudo mysql.server startfixed the issue for me.

我的错误文件还告诉我该端口可能正被另一个进程使用,但只需运行即可sudo mysql.server start为我解决问题。

回答by user3890355

If no one answer helped you, just remove folder /usr/local/var/mysqland then install mysql again brew reinstall mysql.

如果没有人的答案帮助您,只需删除文件夹/usr/local/var/mysql,然后再次安装 mysql brew reinstall mysql

回答by user3890355

Try to remove ib_logfile0and ib_logfile1files and then run mysql again

尝试删除ib_logfile0ib_logfile1文件,然后再次运行 mysql

rm /usr/local/var/mysql/ib_logfile0
rm /usr/local/var/mysql/ib_logfile1

It works for me.

这个对我有用。

回答by Roland Parnaso

I recently came across this issue, however it was working before, then stopped.

我最近遇到了这个问题,但是它之前可以工作,然后停止了。

This was because I initially started mysql.serveras rootinstead of myself.

这是因为我最初是mysql.server作为root而不是我自己开始的。

The fix was to delete the err log file (which was owned by _mysql). Starting it again got it passed.

修复方法是删除 err 日志文件(由 拥有_mysql)。重新开始就通过了。