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.

Community
  • 1
  • 1
Adam_G
  • 7,337
  • 20
  • 86
  • 148
  • 1
    Details related to how to launch MySQL with launchd in Yosemite can be found [in this post](http://stackoverflow.com/q/26461173/1922144). – davidcondrey Oct 21 '14 at 03:12

18 Answers18

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
biniam
  • 8,099
  • 9
  • 49
  • 58
Tommy King
  • 781
  • 1
  • 5
  • 2
  • 8
    Thanks, this worked for me in OSX 10.11 El Capitan as well. – Jeremy Carlson Oct 12 '15 at 03:41
  • 2nd time i've stumbled on this answer when upgrading my other machine. Thanks again! – Catfish Jan 07 '16 at 19:16
  • Same thing happened to me and this fixed it ! I didn't upgrade anything, why was it working before ? Did something change the ownership ? – navid Jul 03 '16 at 15:15
  • 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... thanks – Paulo Griiettner Jul 20 '16 at 19:02
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.

Ares
  • 5,905
  • 3
  • 35
  • 51
  • 2
    The first 2 lines of the file should be: `` ` ` – tfentonz Nov 05 '14 at 02:52
  • 1
    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, though – Adam_G Nov 11 '14 at 16:09
  • @Adam_G in my case I did not have to upgrade MySQL. I kept using the same version I had before upgrading to Yosemite. – Ares Nov 11 '14 at 17:33
  • 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. – Adam_G Nov 11 '14 at 21:33
  • For my comp, MySQL would not start automatically on restart, so I did exactly what you have listed here and it worked perfectly! Thanks :) – double_j Jan 16 '15 at 18:18
  • This is a thing of brilliance! Thanks for the great tips here. – Brian Fegter Mar 20 '15 at 06:33
  • you're lucky then... getting an error "invalid property list" – jwenting Sep 11 '15 at 05:48
  • @jwenting That means you typed/copied something incorrectly. The file is malformed. – Ares Sep 11 '15 at 05:53
  • @Ares 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. – jwenting Sep 11 '15 at 06:14
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

Wils
  • 1,211
  • 17
  • 31
  • 1
    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/ – rlorenzo Sep 30 '15 at 06:38
  • 1
    For el capitan, it is sudo chown -R _mysql:_mysql /usr/local/var/mysql – Mert Metin Jan 18 '16 at 16:00
  • 1
    I had to run `sudo chown -R _mysql:_mysql /usr/local/mysql`, still did not work. – Siddharth Jun 12 '17 at 08:02
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.

Adam_G
  • 7,337
  • 20
  • 86
  • 148
  • 4
    `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: http://stackoverflow.com/a/26492593/922522 – Justin Oct 21 '14 at 17:48
  • 2
    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 @Ares (also noted in the Cool Guides article), fixes that. – Trutane Nov 11 '14 at 01:42
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
KayV
  • 12,987
  • 11
  • 98
  • 148
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.

neilgee
  • 528
  • 1
  • 6
  • 17
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!
EsseTi
  • 4,079
  • 5
  • 36
  • 63
Thomas Dev
  • 91
  • 2
  • 4
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

  • 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!!! – yeelan Mar 11 '15 at 20:29
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..

Vinith
  • 1,264
  • 14
  • 25
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.

Claude COULOMBE
  • 3,434
  • 2
  • 36
  • 39
1

Try this:

sudo mysqld_safe &
  • 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. – Lea Cohen Feb 05 '15 at 20:08
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/.

Per Quested Aronsson
  • 11,380
  • 8
  • 54
  • 76
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

vualoaithu
  • 936
  • 10
  • 9
1

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

json
  • 33
  • 4
0

2 steps solved my problem:

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

2) Restart Yosemite

AamirR
  • 11,672
  • 4
  • 59
  • 73
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
philippinedev
  • 1,220
  • 10
  • 9
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)

Stevers
  • 516
  • 5
  • 11
0

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