MySQL does not start when upgrading OSX to Yosemite or El Capitan
Asked Answered
F

18

68

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.

When I try to start mySQL from the PrefPane, nothing happens.

When I try to start mqSQL from the command line via sudo /usr/local/mysql/support-files/mysql.server start I get:

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.

Filomena answered 20/9, 2014 at 23:25 Comment(1)
Details related to how to launch MySQL with launchd in Yosemite can be found in this post.Abradant
F
26

Solved by installing the latest mySQL release, following the instructions here 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.

Filomena answered 20/9, 2014 at 23:43 Comment(2)
sudo /usr/local/mysql/support-files/mysql.server start is the answer found in the article which explains that the auto-start script fails in the current version of MySQL. To get MySQL to auto-load on start-up of OSX, see: https://mcmap.net/q/263621/-how-to-auto-load-mysql-on-startup-on-os-x-yosemite-el-capitanPammy
Worth noting here is that the installer from mysql.com will bomb out with an "Installation Failed" message. In actuality, the software itself was installed a-OK. The only problem was with the "Start MySQL on Restart" script. The above plist-related tip in the answer from @Irrevocable (also noted in the Cool Guides article), fixes that.Concretize
T
78

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'

  2. If yes, go to the mysql folder cd /usr/local/mysql

  3. do a sudo chown -R _mysql data/

  4. This will change ownership of the /usr/local/mysql/data and all of its content to own by user '_mysql'

  5. Check MySQL system pref panel, it should be saying it's running now, auto-magically. If not start again.

  6. Another way to confirm is to do a

    netstat -na | grep 3306

It should say:

tcp46      0      0  *.3306                 *.*                    LISTEN

To see the process owner and process id of the mysqld:

ps aux | grep mysql
Treasurer answered 5/2, 2015 at 2:54 Comment(4)
Thanks, this worked for me in OSX 10.11 El Capitan as well.Thruster
2nd time i've stumbled on this answer when upgrading my other machine. Thanks again!Ciliate
Same thing happened to me and this fixed it ! I didn't upgrade anything, why was it working before ? Did something change the ownership ?Cablet
The sudo chown -R _mysql data/ did the trick for me on El Capitan after upgrading MySQL from 5.6 to 5.7... Just one thing to note... I had to force quit all mysqld processor on Activity Monitor... thanksDelvalle
I
60

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)

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 : 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.

Irrevocable answered 3/11, 2014 at 1:9 Comment(9)
The first 2 lines of the file should be: <?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">Talia
I actually had to select my answer, to avoid confusion. This question is not about getting mySQL to start automatically. Rather, it was because mySQL needs to be upgraded. Your answer certainly works for the former, thoughFilomena
@Filomena in my case I did not have to upgrade MySQL. I kept using the same version I had before upgrading to Yosemite.Irrevocable
Got it. In my case, it wasn't an issue with the restart, though that was an issue. Maybe this is because the problem occurred for me when Yosemite was still in beta.Filomena
For my comp, MySQL would not start automatically on restart, so I did exactly what you have listed here and it worked perfectly! Thanks :)Ekaterina
This is a thing of brilliance! Thanks for the great tips here.Bream
you're lucky then... getting an error "invalid property list"Guardrail
@Guardrail That means you typed/copied something incorrectly. The file is malformed.Irrevocable
@Irrevocable I typed it in fresh, doublechecked everything. Only thing I can think of is that the file is in the wrong encoding, but using vi that's unlikely.Guardrail
F
34

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:

For el capitan, it is sudo chown -R _mysql:_mysql /usr/local/var/mysql

Fleshly answered 19/6, 2015 at 0:38 Comment(3)
Thanks, worked for me! I was fixing permissions issues according to homebrew, but it doesn't play nice with other stuff installed in /usr/local. BTW, my command was: sudo chown -R _mysql:_mysql /usr/local/mysql/Herc
For el capitan, it is sudo chown -R _mysql:_mysql /usr/local/var/mysqlCalton
I had to run sudo chown -R _mysql:_mysql /usr/local/mysql, still did not work.Lutetium
F
26

Solved by installing the latest mySQL release, following the instructions here 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.

Filomena answered 20/9, 2014 at 23:43 Comment(2)
sudo /usr/local/mysql/support-files/mysql.server start is the answer found in the article which explains that the auto-start script fails in the current version of MySQL. To get MySQL to auto-load on start-up of OSX, see: https://mcmap.net/q/263621/-how-to-auto-load-mysql-on-startup-on-os-x-yosemite-el-capitanPammy
Worth noting here is that the installer from mysql.com will bomb out with an "Installation Failed" message. In actuality, the software itself was installed a-OK. The only problem was with the "Start MySQL on Restart" script. The above plist-related tip in the answer from @Irrevocable (also noted in the Cool Guides article), fixes that.Concretize
C
7

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

sudo /usr/local/mysql/support-files/mysql.server start
Cyndi answered 26/7, 2016 at 10:15 Comment(0)
B
5

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.

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.

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.

Breana answered 19/10, 2014 at 23:38 Comment(0)
G
5

You just need to create the user mysql (mysql installation script creates _mysql)

sudo vipw

duplicate line that contains _mysql

Change for the duplicated line _mysql to mysql

sudo /usr/local/mysql/support-files/mysql.server start
Starting MySQL
.. SUCCESS!
Gleason answered 20/3, 2015 at 14:25 Comment(0)
K
3

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.

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.

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.

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.

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

Here is the script that handles the entire automated installation of MySQL: https://raw.githubusercontent.com/MacMiniVault/Mac-Scripts/master/mmvMySQL/mmvmysql.sh

Kernite answered 10/12, 2014 at 15:10 Comment(1)
Thank you so much @Jon. I tried all the things above and none of them made mysql work on my computer. So I did a total clean up for anything I can find about mysql in the system and ran your install script, which helps! It is just a life saver!!!Kristy
C
2

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

sudo /Applications/XAMPP/xamppfiles/bin/mysql.server start

Remember, it will ask for your Machine password and not mysql password..

Constituency answered 14/1, 2015 at 6:4 Comment(0)
T
2

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

This did the trick for me.

Hoping this can help someone else.

Threescore answered 17/6, 2015 at 4:59 Comment(0)
B
1

Try this:

sudo mysqld_safe &
Bookseller answered 5/2, 2015 at 19:12 Comment(1)
Code blocks on their own are not usually useful answers. If you could please edit your answer and explain what the code you're showing does, and why/how that code answers the question, it could really help.Disincline
M
1

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. More information about the mySQL install script on http://www.macminivault.com/mysql-yosemite/.

Multitudinous answered 11/3, 2015 at 21:21 Comment(0)
C
1

you want fix it can edit file "/Applications/XAMPP/xamppfiles/xampp" with TextEdit.

Look for text "$XAMPP_ROOT/bin/mysql.server start > /dev/null &"
And add "unset DYLD_LIBRARY_PATH" on top of it. It should look like:

unset DYLD_LIBRARY_PATH
$XAMPP_ROOT/bin/mysql.server start > /dev/null &

hope can help you

Centurial answered 23/5, 2015 at 9:4 Comment(0)
T
1

None of the above worked.. but installing a new version of MySQL did the trick.

Torpid answered 10/6, 2015 at 7:19 Comment(0)
S
0

2 steps solved my problem:

1) Delete "/Library/LaunchDaemons/com.mysql.mysql.plist"

2) Restart Yosemite

Scientist answered 27/10, 2015 at 19:29 Comment(0)
R
0

I usually start mysql server by typing

$ mysql.server start

without sudo. But in error I type sudo before the command. Now I have to remove the error file to start the server.

$ sudo rm /usr/local/var/mysql/`hostname`.err
Recrimination answered 23/7, 2016 at 16:8 Comment(0)
L
0

My Mac decided to restart itself randomly; causing a whole slew of errors. One of which, was mysql refusing to start up properly. I went through many SO questions/answers as well as other sites.

Ultimately what ended up resolving MY issue was this:

1) Creating the file (/usr/local/mysql/data/.local.pid

2) chmod 777 on that file

3) executing mysql.server start (mine was located in/usr/local/bin/mysql.server)

Lineal answered 11/8, 2016 at 12:52 Comment(0)
R
0

Same happened to me! So I tried to startup again after I had terminated the running mysql application, and that worked!

Ronnie answered 12/11, 2016 at 8:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.