7

I have installed mysql via brew. First start works, but after reboot, I got the following error:

The server quit without updating PID file (/usr/local/var/mysql/NAME.pid)

I start mysql with

sudo mysql.server restart

If I try to create a pid file on my own via terminal it will created, but after a few seconds it disappear.

sudo touch /usr/local/var/mysql/NAME.pid

Have anyone a idea?

1

9 Answers 9

5

YES.

Following homebrew caveats, did you setup launchd?

To have launchd start mysql at login:
    ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
Then to load mysql now:
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

Well, now using mysql.server is pointless. It basically doesn't work, because (from my poor understanding) mysqld is now managed by launchd, and it is mysqld_safe. I don't know if actually because of that is different from what you control with mysql.server.

The solution I came up with is to not use launchd for mysql from brew. Rather, I just use the mysql.server tool to start, stop, and restart mysql.

If you want to follow my steps, this is what you need to do:

launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

And whenever you want to start the mysql server, use mysql.server start.

If you actually want to make mysql start at boot time, you can take that plist and copy it, delete the KeepAlice line, replace the string values under ProgramArguments with /usr/local/bin/mysql.server and start. After that do
launchctl load ~/path/to/com.file.plist

1
  • 1
    For what it's worth, I don't use mysql.server anymore, instead I use brew services which in turn managed launchd.
    – mcdado
    Commented May 11, 2017 at 18:10
1

try this :

sudo mysqld_safe &

1
  • This worked for me Commented Nov 25, 2023 at 6:21
1

What worked for me was sudo chmod -R 777 /usr/local/mysql/ , I've had installed from brew.

1
  • thanks worked for me. I am wondering why this permission was not there to begin with.
    – Jigar
    Commented Apr 12, 2016 at 7:53
0

just run mysqld (don't run as root) from your terminal, you're mysql server will restarts and resets everything like show in the picture:

enter image description here

and use:

mysql -u root -h 127.0.0.1
0

I had faced the same issue and by following these steps solved it successfully.

Find the file /usr/local/var/mysql/your_computer_name.local.err to understand more about the error.

It's probably a problem with permissions:

  1. Find if mysql is running and kill it

    ps -ef | grep mysql
    kill -9 PID
    

    where PID is second column value

  2. Check ownership of mysql

    ls -laF /usr/local/var/mysql/
    
  3. If it is owned by root, change it to mysql or your user name

    sudo chown -R mysql /usr/local/var/mysql/
    
-1

sudo chmod -R 777 /usr/local/mysql/ worked for me as file permission was not there

-1

Not sure why, but deleting a file called something like /usr/local/var/mysql/Andrejs-MacBook-Pro.local.err and running mysql.server start worked for me.

As detailed here.

-1

This is what I had to do (installed from brew):

sudo chmod -R 777 /usr/local/var/mysql/
-1

For conventional installations, without brew, like mine, the solutions above doesn't worked. The solution came with the permission repair, using the Utilities Disk App from OS X. Just run the app on your disk, restart, and try again. Only solution that worked here.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .