通过 Brew 安装 MySQL 后,出现错误 - 服务器退出而不更新 PID 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9624774/
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
After MySQL install via Brew, I get the error - The server quit without updating PID file
提问by Brajeshwar
Ok, I've searched all over and have spent quite a bit of my time installing, uninstalling, trying various option but without success.
好的,我已经搜索了很多,并且花了很多时间安装、卸载、尝试各种选项但没有成功。
I'm on Mac OS X Lion (10.7.3) and am trying to setup a Python, MySQL.
我在 Mac OS X Lion (10.7.3) 上,正在尝试设置 Python、MySQL。
I successfully installed Python and MySQL via HomeBrew. Python works great.
我通过 HomeBrew 成功安装了 Python 和 MySQL。Python 工作得很好。
After MySQL Installation, I followed the first 2 steps - unset and the mysql_install_db
commands.
安装 MySQL 后,我遵循了前两个步骤 - 取消设置和mysql_install_db
命令。
Now, when I try to start mysql "mysql.server start", I get the following error
现在,当我尝试启动 mysql "mysql.server start" 时,出现以下错误
ERROR! The server quit without updating PID file (/usr/local/var/mysql/Brajeshwar.local.pid).
Brajeshwar
is my username on my machine.
Brajeshwar
是我机器上的用户名。
采纳答案by janmoesen
EDIT 2012/09/18:As pointed out by Kane, make sure the mysql
database is properly set up before doing anything else. See “PID error on mysql.server start?” for more info.
编辑 2012/09/18:正如Kane所指出的,mysql
在做任何其他事情之前,请确保数据库设置正确。请参阅“ mysql.server 启动时出现 PID 错误?”了解更多信息。
Original answer kept for history's sake:It most likely isa permissions issue. Check /usr/local/var/mysql/*.err
. Mine said:
为了历史而保留的原始答案:这很可能是权限问题。检查/usr/local/var/mysql/*.err
。我的说:
120314 16:30:14 InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name ./ibdata1
InnoDB: File operation call: 'open'.
InnoDB: Cannot continue operation.
120314 16:30:14 mysqld_safe mysqld from pid file /usr/local/var/mysql/janmoesen.local.pid ended
I also had to do this:
我也必须这样做:
sudo chown _mysql /usr/local/var/mysql/*
回答by mikoop
I found that it was a permissions issue with the mysql
folder.
我发现这是mysql
文件夹的权限问题。
chmod -R 777 /usr/local/var/mysql/
solved it for me.
为我解决了。
回答by artnikpro
I ended up with completely reinstalling of mysql, and it finally worked out.
我最终完全重新安装了mysql,终于解决了。
WARNINGThis will remove all of your databases, so make sure to save dumps first.
警告这将删除您的所有数据库,因此请确保先保存转储。
brew remove mysql
brew cleanup
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
sudo rm -rf /usr/local/var/mysql
brew install mysql
mysqld --initialize --explicit_defaults_for_timestamp
mysql.server start # no sudo!
回答by Rakesh James
I had this issue on mac 10.10.5 Yosemite
我在 mac 10.10.5 Yosemite 上遇到了这个问题
What I did to solve this
我做了什么来解决这个问题
cd /usr/local/var/mysql
sudo rm *.err && sudo rm *.pid
sudo reboot
sudo mysql.server start
cd /usr/local/var/mysql
sudo rm *.err && sudo rm *.pid
sudo reboot
sudo mysql.server start
回答by phpguru
November, 2014: If you're getting this error on MySQL 5.6.x on Mac OS X Mavericks or Yosemite and want to use MySQL with PHP locally (/tmp/mysql.sock is where PHP PDO expects to find the sock file), here is what fixed it for me:
2014 年 11 月:如果您在 Mac OS X Mavericks 或 Yosemite 上的 MySQL 5.6.x 上遇到此错误,并希望在本地使用 MySQL 和 PHP(/tmp/mysql.sock 是 PHP PDO 希望找到 sock 文件的位置),这是为我解决的问题:
1) Uncomment the default homebrew config file lines and edit as below
1)取消注释默认的自制配置文件行并编辑如下
$ sudo vi /usr/local/Cellar/mysql/5.6.21/my.cnf
...
basedir = /usr/local/Cellar/mysql/5.6.21
datadir = /usr/local/var/mysql
port = 3306
server_id = <UNIQUE_NUMBER_HERE_OR_LEAVE_COMMENTED_OUT>
socket = /tmp/mysql.sock
pid-file = /usr/local/var/mysql/[BOXNAME].local.pid
....
BOXNAME is what you have in your System Prefs -> Network as the unique id for your computer on the network.
BOXNAME 是您在 System Prefs -> Network 中拥有的内容,作为您的计算机在网络上的唯一 ID。
2) Set permissions on all the files in the mysql datadir. These were all owned by [my_username]. MySQL is very picky about this and refuses to create the pid file unless it (the user _mysql) owns the directory.
2) 为mysql datadir 中的所有文件设置权限。这些都归 [my_username] 所有。MySQL 对此非常挑剔并且拒绝创建 pid 文件,除非它(用户 _mysql)拥有该目录。
$ sudo chown -R _mysql:mysql /usr/local/var/mysql
3) Start MySQL using the bash helper/wrapper script:
3) 使用 bash helper/wrapper 脚本启动 MySQL:
$ sudo mysql.server start
Starting MySQL
. SUCCESS!
Hope that helps. If the above doesn't work for you, try to run the mysqld_safe binary manually in the Cellar/mysql/VERSION_/bin/ directory and check what the settings are (if it runs)
希望有帮助。如果上述方法对您不起作用,请尝试在 Cellar/mysql/VERSION_/bin/ 目录中手动运行 mysqld_safe 二进制文件并检查设置是什么(如果运行)
sudo /usr/local/Cellar/mysql/5.6.12/bin/mysqld_safe &
If that runs, you can
如果它运行,你可以
ps aux | grep mysql
and see something like
看到类似的东西
[username] 6881 0.0 2.7 3081392 454836 ?? S 8:52AM 0:00.54 /usr/local/Cellar/mysql/5.6.21/bin/mysqld --basedir=/usr/local/Cellar/mysql/5.6.21 --datadir=/usr/local/var/mysql --plugin-dir=/usr/local/Cellar/mysql/5.6.21/lib/plugin --verbose --log-error=/usr/local/var/mysql/BOXNAME.local.err --pid-file=/usr/local/var/mysql/BOXNAME.local.pid
I'm not sure why that worked for me but it shows you where I got the my.cnf config file options from. You can also use the command line options to try to troubleshoot when starting mysqld manually.
我不确定为什么这对我有用,但它显示了我从哪里获得 my.cnf 配置文件选项。您还可以使用命令行选项尝试手动启动 mysqld 时进行故障排除。
If you do run manage to run MySQL server using mysqld_safe, you may have to do this to shut it down before trying the mysql.server bash helper. Resist the urge to kill -9 [PID] because you can corrupt your data.
如果您确实使用 mysqld_safe 运行 manage 来运行 MySQL 服务器,则在尝试 mysql.server bash helper 之前,您可能必须这样做以将其关闭。抵制杀死 -9 [PID] 的冲动,因为您可能会损坏您的数据。
mysqladmin -uroot shutdown
Good luck!
祝你好运!
回答by Circle B
I had the same issue on OS X El Capitan, here's the terminal command sequence that fixed it for me.
我在 OS X El Capitan 上遇到了同样的问题,这是为我修复它的终端命令序列。
Delete error files (you'll have to change the path depending on your setup)
删除错误文件(您必须根据您的设置更改路径)
sudo rm /usr/local/mysql/data/*.err
Find the info for the mysql process that's still running and kill it:
找到仍在运行的 mysql 进程的信息并杀死它:
ps -A | grep -m1 mysql | awk '{print }' | sudo xargs kill -9
Now restart MySQL:
现在重启 MySQL:
/usr/local/mysql/support-files/mysql.server start
回答by Kresimir Plese
This worked for me:
这对我有用:
sudo chmod -R 777 /usr/local/var/mysql/
sudo /usr/local/mysql/support-files/mysql.server start
回答by Suryanto Rachmat
This worked for me on 10.12.2 :
这在 10.12.2 上对我有用:
$ rm /usr/local/var/mysql/*.err
then
然后
$ brew services restart mysql
回答by LonnyLot
If I remember correctly it is a permissions issue. Try to 'touch' and 'chmod' the pid file or the folder the file is held in.
如果我没记错的话,这是一个权限问题。尝试“触摸”和“chmod”pid 文件或文件所在的文件夹。
回答by Grimmo
My issue was that I started server as sudo once and then tried to restart as a local user.
我的问题是我以 sudo 身份启动服务器一次,然后尝试以本地用户身份重新启动。
Here mysql was not able to write to '.err' file owned by root. I had to remove that file and restart the server:
这里 mysql 无法写入 root 拥有的“.err”文件。我必须删除该文件并重新启动服务器:
sudo rm /usr/local/var/mysql/*.err
mysql.server start