91
votes

Ok, I've searched all over and have spent quite a bit of my time installing, uninstalling, trying various option but without success.

I'm on Mac OS X Lion (10.7.3) and am trying to setup a Python, MySQL.

I successfully installed Python and MySQL via HomeBrew. Python works great.

After MySQL Installation, I followed the first 2 steps - unset and the mysql_install_db commands.

Now, when I try to start mysql "mysql.server start", I get the following error

ERROR! The server quit without updating PID file (/usr/local/var/mysql/Brajeshwar.local.pid).
  • Brajeshwar is my username on my machine.
30

30 Answers

105
votes

I found that it was a permissions issue with the mysql folder.

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

solved it for me.

85
votes

EDIT 2012/09/18: As pointed out by Kane, make sure the mysql database is properly set up before doing anything else. See “PID error on mysql.server start?” for more info.

Original answer kept for history's sake: It most likely is a permissions issue. Check /usr/local/var/mysql/*.err. Mine said:

120314 16:30:14  InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name ./ibdata1
InnoDB: File operation call: 'open'.
InnoDB: Cannot continue operation.
120314 16:30:14 mysqld_safe mysqld from pid file /usr/local/var/mysql/janmoesen.local.pid ended

I also had to do this:

sudo chown _mysql /usr/local/var/mysql/*
68
votes

I ended up with completely reinstalling of mysql, and it finally worked out.

WARNING This will remove all of your databases, so make sure to save dumps first.

brew remove mysql
brew cleanup
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
sudo rm -rf /usr/local/var/mysql

brew install mysql
mysqld --initialize --explicit_defaults_for_timestamp
mysql.server start # no sudo!
32
votes

I had this issue on mac 10.10.5 Yosemite

What I did to solve this

cd /usr/local/var/mysql
sudo rm *.err && sudo rm *.pid
sudo reboot
sudo mysql.server start

19
votes

I had the same issue on OS X El Capitan, here's the terminal command sequence that fixed it for me.

Delete error files (you'll have to change the path depending on your setup)

sudo rm /usr/local/mysql/data/*.err

Find the info for the mysql process that's still running and kill it:

ps -A | grep -m1 mysql | awk '{print $1}' | sudo xargs kill -9

Now restart MySQL:

/usr/local/mysql/support-files/mysql.server start
18
votes

November, 2014: If you're getting this error on MySQL 5.6.x on Mac OS X Mavericks or Yosemite and want to use MySQL with PHP locally (/tmp/mysql.sock is where PHP PDO expects to find the sock file), here is what fixed it for me:

1) Uncomment the default homebrew config file lines and edit as below

$ sudo vi /usr/local/Cellar/mysql/5.6.21/my.cnf
...
basedir = /usr/local/Cellar/mysql/5.6.21
datadir = /usr/local/var/mysql
port = 3306
server_id = <UNIQUE_NUMBER_HERE_OR_LEAVE_COMMENTED_OUT>
socket = /tmp/mysql.sock
pid-file = /usr/local/var/mysql/[BOXNAME].local.pid
....

BOXNAME is what you have in your System Prefs -> Network as the unique id for your computer on the network.

2) Set permissions on all the files in the mysql datadir. These were all owned by [my_username]. MySQL is very picky about this and refuses to create the pid file unless it (the user _mysql) owns the directory.

$ sudo chown -R _mysql:mysql /usr/local/var/mysql

3) Start MySQL using the bash helper/wrapper script:

$ sudo mysql.server start
Starting MySQL
. SUCCESS! 

Hope that helps. If the above doesn't work for you, try to run the mysqld_safe binary manually in the Cellar/mysql/VERSION_/bin/ directory and check what the settings are (if it runs)

sudo /usr/local/Cellar/mysql/5.6.12/bin/mysqld_safe &

If that runs, you can

ps aux | grep mysql 

and see something like

[username]  6881   0.0  2.7  3081392 454836   ??  S     8:52AM   0:00.54 /usr/local/Cellar/mysql/5.6.21/bin/mysqld --basedir=/usr/local/Cellar/mysql/5.6.21 --datadir=/usr/local/var/mysql --plugin-dir=/usr/local/Cellar/mysql/5.6.21/lib/plugin --verbose --log-error=/usr/local/var/mysql/BOXNAME.local.err --pid-file=/usr/local/var/mysql/BOXNAME.local.pid

I'm not sure why that worked for me but it shows you where I got the my.cnf config file options from. You can also use the command line options to try to troubleshoot when starting mysqld manually.

If you do run manage to run MySQL server using mysqld_safe, you may have to do this to shut it down before trying the mysql.server bash helper. Resist the urge to kill -9 [PID] because you can corrupt your data.

mysqladmin -uroot shutdown

Good luck!

10
votes

This worked for me:

sudo chmod -R 777 /usr/local/var/mysql/
sudo /usr/local/mysql/support-files/mysql.server start
5
votes

This worked for me on 10.12.2 :

$ rm /usr/local/var/mysql/*.err

then

$ brew services restart mysql
3
votes

If I remember correctly it is a permissions issue. Try to 'touch' and 'chmod' the pid file or the folder the file is held in.

3
votes

My issue was that I started server as sudo once and then tried to restart as a local user.

Here mysql was not able to write to '.err' file owned by root. I had to remove that file and restart the server:

sudo rm /usr/local/var/mysql/*.err
mysql.server start
2
votes

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.

1
votes

For me it worked with:

unset TMPDIR
mysql_install_db --user=`whoami` --basedir="$(brew --prefix mariadb)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
1
votes

What worked for me was:

  1. Go to your mysql installation directory
  2. sudo chmod -R 777 data
  3. Then go back one directory
  4. cd support-files/
  5. sudo ./mysql.server start

After that the server started running.

But the problem with this method is that I have to repeat this every time I want to start the mysql now. Don't know why it started behaving like this suddenly.

1
votes

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

Location : /usr/local/var/mysql/your_computer_name.local.err

It's probably 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/

if it is owned by root, change it mysql or your user name



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

1
votes

Try this (OSX)

Step 1: ps -aux | grep mysql

Then kill the 4 digits PID number

Step 2: kill 1965

Step 3: mysql.server start

Or having hard time to locate those PID numbers, try this below

Step 1 again: ps -aux | grep mysql

Step 2 again: killall

Step 3 again: mysql.server start

1
votes

If you have upgraded your mysql installation to 8.x, check if your previous version is supported for upgradation.

If not, mysql will not work! Uninstall your mysql along with all configuration files in /usr/local/var/mysql (remove the whole folder). Reinstall mysql.

NOTE: reinstalling might lead to loss of data.

1
votes

Please check the log , you will get more detailed information .

Use the below command to tail the error log

tail -100 /usr/local/var/mysql/<user_name>.local.err

For me , one of the directory is missing , once created the server has started .

1
votes

The key takeaway is to check the .err file, by default on Mac OSX it's in /usr/local/var/mysql.

That log filed revealed to me that I had to delete the following files:

ibdata1
ib_logfile0
ib_logfile1

Running MySQL with mysql.start worked successfully after that. Note that deleting those files will likely causes data loss.

0
votes
sudo chmod -R 777 /usr/local/var/mysql/

works for me.

0
votes

I had the same issue:

But the situation was, every time i try to enter:

/usr/local/mysql/support-files/mysql.server start

a file named localhost.pid is created instead of iMax0.local.pid which was stated in the error:

ERROR! The server quit without updating PID file (/usr/local/mysql/data/iMax0.local.pid).

Solution that works for me was copying localhost.pid and renaming it to iMax0.local.pid.

0
votes

My solution on OSX El Capitan was:

sudo chmod ugo+w /tmp

It was broken suddenly.

The error was:

ERROR! The server quit without updating PID file

and the log showed:

Can't start server : Bind on unix socket: Permission denied

It might also be helpful to note, that under OSX there is no my.cnf file by default and not needed by default, which I did not know. Good luck!

0
votes
$ sudo mysql.server restart

It works for me.

0
votes

I had the similar issue. But the following commands saved me.

cd /usr/local/Cellar
sudo chown _mysql mysql
0
votes

This is file permission problem. Check disk permissions and repair.

Osx => Cmd+Space => Disk Utilty => Verify Disk Permissions.

Verify completed after Repair Disk Permissions. mysql.server start command is worked succesfuly.

0
votes

None of the answers worked for me. However, I simply did sudo mysql.server start and it worked nicely.

Also, for me, it did NOT show permissions issue in *.err file.

0
votes

I had this problem on Linux, but the cause is relevant to any mysql installation. In my case, the server was crashing before startup was complete and the pid file updated. The error messages were seen when starting up mysqld directly instead of via "service mysql start".

In my case, the cause was the partition where the log files were located being full. Removing log files permitted mysql to start again. To test for this issue, go to the location of your mysql activity logs, and do df ..

0
votes

all solutions above doesn't work for me. but they give me some clues to fix this error.

mysql.server start ----error The server quit without updating PID file

I installed [email protected] on my macbook mojave with homebrew

brew install [email protected]

mysql error log located in /usr/local/var/mysql/IU.lan.err,there is one line in it: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist

after trying many posts in goole search engine,I turned to baidu https://blog.csdn.net/xhool/article/details/52398042 inspired by this post,I found the solution:

rm /usr/local/var/mysql/*

mysqld --initialize

a random password for root user will be shown in bash. but the command mysql -uroot -p[theRandomPassword] cant work.so I have to reset password. create a init file with contents like this

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPass');

place it in any directory easy to find,such as Desktop

mysqld --init-file=[YourInitFile] &

many logs printed on your screen.

mysql -uroot -pMyNewPass

enjoy your high-version mysql!

0
votes

Happened to me because I was actually switching from MariaDB to Mysql. Switching back to MariaDB solved this.

I'm guessing the existing database wasn't compatible.

0
votes

Solved this using sudo chown -R _mysql:_mysql /usr/local/var/mysql Thanks to Matteo Alessani

0
votes

This error may be actually being show because mysql is already started. Try to see the current status by:

mysql.server status