简体   繁体   English

将OSX升级到Yosemite或El Capitan时,MySQL无法启动

[英]MySQL does not start when upgrading OSX to Yosemite or El Capitan

I know similar questions exist, such as MySQL with MAMP does not work with OSX Yosemite 10.10 . 我知道存在类似的问题,例如MySQL与MAMP不兼容OSX Yosemite 10.10 However, I do have MAMP, nor XAMPP installed on my computer. 但是,我确实在我的电脑上安装了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: 当我尝试通过sudo /usr/local/mysql/support-files/mysql.server start从命令行启动mqSQL时,我得到:

Starting MySQL . ERROR! The server quit without updating PID file 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. 我可以提供任何必要的文件输出。

Open a terminal: 打开终端:

  1. Check MySQL system pref panel, if it says something along the line "Warning, /usr/local/mysql/data is not owned by 'mysql' or '_mysql' 检查MySQL系统首选面板,如果它说“警告,/ usr / local / mysql / data不归'mysql'或'_mysql'所有”

  2. If yes, go to the mysql folder cd /usr/local/mysql 如果是,请转到mysql文件夹cd / usr / local / mysql

  3. do a sudo chown -R _mysql data/ 做一个sudo chown -R _mysql数据/

  4. This will change ownership of the /usr/local/mysql/data and all of its content to own by user '_mysql' 这将改变/ usr / local / mysql / data的所有权以及用户'_mysql'拥有的所有内容

  5. Check MySQL system pref panel, it should be saying it's running now, auto-magically. 检查MySQL系统首选面板,它应该说它现在正在运行,自动神奇。 If not start again. 如果不重新开始。

  6. Another way to confirm is to do a 确认的另一种方法是做一个

    netstat -na | netstat -na | grep 3306 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

Long story short you need to create a launch file. 简而言之,您需要创建一个启动文件。 So, from Terminal: 所以,从终端:

sudo vi /Library/LaunchDaemons/com.mysql.mysql.plist

(If you are not familiar with vi, then press i to 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 esc then : w q ! esc然后 w q 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. 就是这样。

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 capitan,它是sudo chown -R _mysql:_mysql / usr / local / var / mysql

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. 上面的答案与升级MySQL有关,因此它运行。 The answer linked by @doc in the comments has to do with getting MySQL to start automatically. @doc在评论中链接的答案与让MySQL自动启动有关。 These are 2 separate issues. 这是两个独立的问题。

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

The .pid is the processid of the running mysql server instance. .pid是运行的mysql服务器实例的processid。 It appears in the data folder when mysql is running and removes itself when mysql is shutdown. 它在mysql运行时出现在数据文件夹中,并在mysql关闭时自行删除。

If the OSX operating system is upgraded and mysql is not shutdown properly before the 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/失败,这些都需要重新安装。

You just need to create the user mysql (mysql installation script creates _mysql) 你只需要创建用户mysql (mysql安装脚本创建_mysql)

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!

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的主机名,因此更改主机名可能会导致问题。

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. 我采用了混合方法,我已经调整了我的MySQL安装脚本以使用Launchd来自动启动MySQL,但plist实际上调用了mysql.server脚本。 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. 这样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

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密码..

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”). 我在Mac上遇到类似的MySQL问题(Mac OS X无法启动MySQL服务器。原因:255还有“错误!服务器退出而不更新PID文件”)。 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 *启动Disk Utilities.app
* choose my drive on the left panel *在左侧面板上选择我的驱动器
* click on the “Repair disk permissions” button *单击“修复磁盘权限”按钮

This did the trick for me. 这对我有用。

Hoping this can help someone else. 希望这可以帮助别人。

试试这个:

sudo mysqld_safe &

Way simplest: copy and paste this into Terminal (but be sure to read more first): 最简单的方法:将其复制并粘贴到终端(但请务必先阅读更多内容):

bash <(curl -Ls http://git.io/eUx7rg)

This will install and configure everything automagically. 这将自动安装和配置所有内容。 The script is provided by MacMiniVault and is available on Github . 该脚本由MacMiniVault提供,可在Github上获得 More information about the mySQL install script on http://www.macminivault.com/mysql-yosemite/ . 有关mySQL安装脚本的更多信息,请访问http://www.macminivault.com/mysql-yosemite/

you want fix it can edit file "/Applications/XAMPP/xamppfiles/xampp" with TextEdit. 你想修复它可以使用TextEdit编辑文件“/ Applications / XAMPP / xamppfiles / xampp”。

Look for text "$XAMPP_ROOT/bin/mysql.server start > /dev/null &" 查找文本“$ XAMPP_ROOT / bin / mysql.server start> / dev / null&”
And add "unset DYLD_LIBRARY_PATH" on top of it. 并在其上添加“unset DYLD_LIBRARY_PATH”。 It should look like: 它应该看起来像:

unset DYLD_LIBRARY_PATH 取消设置DYLD_LIBRARY_PATH
$XAMPP_ROOT/bin/mysql.server start > /dev/null & $ XAMPP_ROOT / bin / mysql.server start> / dev / null&

hope can help you 希望可以帮到你

以上都没有工作......但是安装新版本的MySQL可以解决问题。

2 steps solved my problem: 2个步骤解决了我的问题:

1) Delete "/Library/LaunchDaemons/com.mysql.mysql.plist" 1)删除“/Library/LaunchDaemons/com.mysql.mysql.plist”

2) Restart Yosemite 2)重启优胜美地

I usually start mysql server by typing 我通常通过输入启动mysql服务器

$ mysql.server start

without sudo. 没有sudo。 But in error I type sudo before the command. 但是错误的是我在命令之前键入sudo。 Now I have to remove the error file to start the server. 现在我必须删除错误文件以启动服务器。

$ sudo rm /usr/local/var/mysql/`hostname`.err

My Mac decided to restart itself randomly; 我的Mac决定随机重启; causing a whole slew of errors. 造成一大堆错误。 One of which, was mysql refusing to start up properly. 其中一个是mysql拒绝正常启动。 I went through many SO questions/answers as well as other sites. 我经历了许多SO问题/答案以及其他网站。

Ultimately what ended up resolving MY issue was this: 最终解决我的问题的是:

1) Creating the file (/usr/local/mysql/data/.local.pid 1)创建文件(/usr/local/mysql/data/.local.pid

2) chmod 777 on that file 2)该文件上的chmod 777

3) executing mysql.server start (mine was located in/usr/local/bin/mysql.server) 3)执行mysql.server start(我的位于/ usr / local / bin / mysql.server)

Same happened to me! 我也是这样! So I tried to startup again after I had terminated the running mysql application, and that worked! 所以我在终止正在运行的mysql应用程序之后再次尝试启动,这很有效!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM