将 OSX 升级到 Yosemite 或 El Capitan 时,MySQL 不启动
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25954230/
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
MySQL does not start when upgrading OSX to Yosemite or El Capitan
提问by Adam_G
I know similar questions exist, such as MySQL with MAMP does not work with OSX Yosemite 10.10. However, I do have MAMP, nor XAMPP installed on my computer.
我知道存在类似的问题,例如带有 MAMP 的 MySQL 不适用于 OSX Yosemite 10.10。但是,我的计算机上确实安装了 MAMP,也没有安装 XAMPP。
When I try to start mySQL from the PrefPane, nothing happens.
当我尝试从 PrefPane 启动 mySQL 时,没有任何反应。
When I try to start mqSQL from the command line via sudo /usr/local/mysql/support-files/mysql.server start
I get:
当我尝试通过命令行从命令行启动 mqSQL 时,sudo /usr/local/mysql/support-files/mysql.server start
我得到:
Starting MySQL . ERROR! The server quit without updating PID file
(/usr/local/mysql/data/adamg.local.pid).
Starting MySQL . ERROR! The server quit without updating PID file
(/usr/local/mysql/data/adamg.local.pid).
Any and all help would be appreciated. I can supply any file output necessary.
任何和所有帮助将不胜感激。我可以提供任何必要的文件输出。
采纳答案by Adam_G
Solved by installing the latest mySQL release, following the instructions here http://coolestguidesontheplanet.com/get-apache-mysql-php-phpmyadmin-working-osx-10-10-yosemite/
通过安装最新的 mySQL 版本解决,按照这里的说明http://coolestguidesontheplanet.com/get-apache-mysql-php-phpmyadmin-working-osx-10-10-yosemite/
EDIT
As Yosemite gets more popular, more people are stumbling on this question. The answer above has to do with upgrading MySQL, so that it runs. The answer linked by @doc in the comments has to do with getting MySQL to start automatically. These are 2 separate issues.
编辑
随着优胜美地越来越受欢迎,越来越多的人在这个问题上磕磕绊绊。上面的答案与升级 MySQL 有关,以便它运行。@doc 在评论中链接的答案与让 MySQL 自动启动有关。这是两个独立的问题。
回答by Tommy King
Open a terminal:
打开终端:
Check MySQL system pref panel, if it says something along the line "Warning, /usr/local/mysql/data is not owned by 'mysql' or '_mysql'
If yes, go to the mysql folder cd /usr/local/mysql
do a sudo chown -R _mysql data/
This will change ownership of the /usr/local/mysql/data and all of its content to own by user '_mysql'
Check MySQL system pref panel, it should be saying it's running now, auto-magically. If not start again.
Another way to confirm is to do a
netstat -na | grep 3306
检查 MySQL 系统偏好面板,如果它显示“警告,/usr/local/mysql/data 不属于 'mysql' 或 '_mysql'
如果是,转到mysql文件夹cd /usr/local/mysql
做一个sudo chown -R _mysql data/
这会将 /usr/local/mysql/data 及其所有内容的所有权更改为用户“_mysql”所有
检查 MySQL 系统偏好面板,它应该说它现在正在运行,自动神奇。如果没有重新开始。
另一种确认方法是做一个
netstat -na | grep 3306
It should say:
它应该说:
tcp46 0 0 *.3306 *.* LISTEN
To see the process owner and process id of the mysqld:
要查看 mysqld 的进程所有者和进程 ID:
ps aux | grep mysql
回答by Ares
Long story short you need to create a launch file. So, from Terminal:
长话短说,您需要创建一个启动文件。所以,从终端:
sudo vi /Library/LaunchDaemons/com.mysql.mysql.plist
sudo vi /Library/LaunchDaemons/com.mysql.mysql.plist
(If you are not familiar with vi, then press ito start inserting text)
(如果你不熟悉vi,那么按i开始插入文本)
This should be the content of your file:
这应该是您文件的内容:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true />
<key>Label</key>
<string>com.mysql.mysqld</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/mysql/bin/mysqld_safe</string>
<string>--user=mysql</string>
</array>
</dict>
</plist>
press escthen :wq!enter
按esc然后:wq!enter
Then you need to give the file the right permissions and set it to load on startup.
然后您需要为文件赋予正确的权限并将其设置为在启动时加载。
sudo chown root:wheel /Library/LaunchDaemons/com.mysql.mysql.plist
sudo chmod 644 /Library/LaunchDaemons/com.mysql.mysql.plist
sudo launchctl load -w /Library/LaunchDaemons/com.mysql.mysql.plist
And that is it.
就是这样。
回答by Wils
In my case I fixed it doing a little permission change:
在我的情况下,我修复了它并做了一些权限更改:
sudo chown -R _mysql:_mysql /usr/local/var/mysql
sudo mysql.server start
I hope it helps somebody else...
我希望它可以帮助别人...
Note:As per Mert Mertin comment:
注意:根据 Mert Mertin 评论:
For el capitan, it is sudo chown -R _mysql:_mysql /usr/local/var/mysql
对于 el capan,它是 sudo chown -R _mysql:_mysql /usr/local/var/mysql
回答by KayV
Execute the following commands from command line...
从命令行执行以下命令...
sudo launchctl load -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
sudo launchctl unload -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
and then start the mysql server using
然后使用启动mysql服务器
sudo /usr/local/mysql/support-files/mysql.server start
回答by neilgee
The .pid is the processid of the running mysql server instance. It appears in the data folder when mysql is running and removes itself when mysql is shutdown.
.pid 是正在运行的 mysql 服务器实例的 processid。它在 mysql 运行时出现在数据文件夹中,并在 mysql 关闭时自行删除。
If the OSX operating system is upgraded and mysql is not shutdown properly beforethe upgrade,mysql quits when it started up it just quits because of the .pid file.
如果OSX操作系统升级了,升级前mysql没有正常关闭,mysql启动就退出了,只是因为.pid文件退出了。
There are a few tricks you can try, http://coolestguidesontheplanet.com/mysql-error-server-quit-without-updating-pid-file/failing these a reinstall is needed.
您可以尝试一些技巧,http://coolestguidesontheplanet.com/mysql-error-server-quit-without-updating-pid-file/如果失败,则需要重新安装。
回答by Thomas Dev
You just need to create the user mysql
(mysql installation script creates _mysql)
你只需要创建用户mysql
(mysql安装脚本创建_mysql)
sudo vipw
sudo vipw
duplicate line that contains _mysql
包含的重复行 _mysql
Change for the duplicated line _mysql
to mysql
更改为复制线_mysql
,以mysql
sudo /usr/local/mysql/support-files/mysql.server start
Starting MySQL
.. SUCCESS!
回答by Jon Schwenn
The re-install fixed it because the installer created a new MySQL instance and the symbolic link to /usr/local/mysql now points to a data directory that does not have an existing pid.
重新安装修复了它,因为安装程序创建了一个新的 MySQL 实例,并且 /usr/local/mysql 的符号链接现在指向一个没有现有 pid 的数据目录。
It's worth noting that the mysql prefpane and mysql.server script use the hostname for the pid, so changing the hostname may cause issues with the this.
值得注意的是,mysql prefpane 和 mysql.server 脚本使用主机名作为 pid,因此更改主机名可能会导致 this 出现问题。
While the prefpane is out of date, it's a nice GUI for someone to start/stop MySQL even if the auto-start function doesn't work.
虽然 prefpane 已经过时了,但它是一个很好的 GUI,即使自动启动功能不起作用,也有人可以启动/停止 MySQL。
I've taken a hybrid approach where I've adapted my MySQL install script to use Launchd to auto-start MySQL, but the plist actually calls the mysql.server script. This way the prefpane can still be used to start/stop MySQL on demand, and trying to do a simple MySQL restart won't be too confusing.
我采用了一种混合方法,其中我调整了我的 MySQL 安装脚本以使用 Launchd 来自动启动 MySQL,但 plist 实际上调用了 mysql.server 脚本。这样 prefpane 仍然可以用于按需启动/停止 MySQL,并且尝试执行简单的 MySQL 重启不会太混乱。
Here is script that just enables this Launchd behavior on Yosemite with MySQL already installed: https://raw.githubusercontent.com/MacMiniVault/Mac-Scripts/master/mmvMySQL/YosemiteLaunchd.sh
这是在已安装 MySQL 的情况下在 Yosemite 上启用此 Launchd 行为的脚本:https: //raw.githubusercontent.com/MacMiniVault/Mac-Scripts/master/mmvMySQL/YosemiteLaunchd.sh
Here is the script that handles the entire automated installation of MySQL: https://raw.githubusercontent.com/MacMiniVault/Mac-Scripts/master/mmvMySQL/mmvmysql.sh
这是处理 MySQL 的整个自动安装的脚本:https: //raw.githubusercontent.com/MacMiniVault/Mac-Scripts/master/mmvMySQL/mmvmysql.sh
回答by Vinith
You will sometimes miss previous data if you try to install new version.. Please use the following in your terminal and I guarantee that mySql will start running in no time..
如果您尝试安装新版本,有时会错过以前的数据。请在终端中使用以下内容,我保证 mySql 将立即开始运行。
sudo /Applications/XAMPP/xamppfiles/bin/mysql.server start
Remember, it will ask for your Machine password and not mysql password..
请记住,它会询问您的机器密码而不是 mysql 密码。
回答by Claude COULOMBE
I've got a similar problem with MySQL on a Mac (Mac Os X Could not startup MySQL Server. Reason: 255 and also “ERROR! The server quit without updating PID file”). After a long trial and error process, finally in order to restore the file permissions, I've just do that:
* launch the Disk Utilities.app
* choose my drive on the left panel
* click on the “Repair disk permissions” button
我在 Mac 上遇到了与 MySQL 类似的问题(Mac Os X 无法启动 MySQL 服务器。原因:255 以及“错误!服务器在没有更新 PID 文件的情况下退出”)。经过长时间的反复试验,最后为了恢复文件权限,我只是这样做:
* 启动 Disk Utilities.app
* 在左侧面板上选择我的驱动器
* 单击“修复磁盘权限”按钮
This did the trick for me.
这对我有用。
Hoping this can help someone else.
希望这可以帮助别人。