108

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.

34 Answers 34

119

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

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

solved it for me.

Sign up to request clarification or add additional context in comments.

12 Comments

there is no need to make this 777
I was also searching for a long time and this is what fixed it for me.
Please note I do not recommend setting anything to 777 in a production environment. This needs to be on a local install only. I would also switch it back to 755 as a minimum.
If you see error on mysql start Warning: World-writable config file '/var/lib/mysql/none-dev/my.cnf' is ignored Then you'll probably want to chmod o-w /var/lib/mysql/none-dev/my.cnf
sudo can be needed !
|
94

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

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! 

16 Comments

I tried changing permissions in every possible way without success. Ended up following these instructions and... success :)
This is the ONLY solution I found. This should be number one
Thanks, this is the only thing that worked for me. Although I didn't have to run mysqld --initialize --explicit_defaults_for_timestamp
Starting MySQL ... ERROR! The server quit without updating PID file (<path>-.lightspeed.irvnca.sbcglobal.net.pid). Getting this error
Just homebrew issue
|
87

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/* 

9 Comments

I solved the issue running: sudo chown -R _mysql:_mysql /usr/local/var/mysql
I get the same error, but I have no /usr/local/var/mysql folder :( I am also using homebrew.
See the comments of brew info mysql or this question for right solution
sudo chmod ugo+w /tmp was my solution.
mine was solved with sudo chown -R {my_user_name}:admin /usr/local/var/mysql55/
|
35

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

Comments

19

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 

Comments

17

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!

1 Comment

thanks - mine was solved with sudo chown -R {my_user_name}:admin /usr/local/var/mysql55/
10

This worked for me:

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

2 Comments

This solved my issue in MAC os 10.11.3 (after changing mode to 777 of the mysql dir)
This means Read Write Execute, or full rights to all users to that folder and (-R) all files and folders under that folder. For detailed explanation, please take a look at the following link: linux.com/learn/understanding-linux-file-permissions
8

This worked for me on 10.12.2 :

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

then

$ brew services restart mysql 

Comments

3

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.

2 Comments

Nope. I even tried chmod 777 to see if that solves the problem but nothing. Same ERROR.
Did you try to chmod 777 the mysql directory and deleting the pid file and restarting MySQL?
3

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 

Comments

3

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 Comment

ps: No user named 'x'
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.

Comments

2

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/

Comments

2

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 .

Comments

1

For me it worked with:

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

Comments

1

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.

Comments

1

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

Comments

1

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.

Comments

1

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.

Comments

1

I was encountering this error whilst starting mysql that was installed VIA BREW, mysql was working perfectly all this time until last week i started it and ran into this pretty fella. I get the same error when running brew services start mysql:

\W $mysql.server start Starting MySQL . ERROR! The server quit without updating PID file (/opt/homebrew/var/mysql/MYDEVICE.local.pid). 

What worked for me was this. I first ran brew info mysql

\W $brew info mysql ==> mysql: stable 9.0.1 (bottled) Open source relational database management system https://dev.mysql.com/doc/refman/9.0/en/ Conflicts with: mariadb (because both install the same binaries) percona-server (because both install the same binaries) Installed /opt/homebrew/Cellar/mysql/9.0.1_7 (324 files, 308.8MB) * Poured from bottle using the formulae.brew.sh API on 2024-12-01 at 17:32:40 From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/m/mysql.rb License: GPL-2.0-only WITH Universal-FOSS-exception-1.0 ==> Dependencies Build: bison ✘, cmake ✘, pkgconf ✔ Required: abseil ✔, icu4c@76 ✔, lz4 ✔, openssl@3 ✔, protobuf ✔, zlib ✔, zstd ✔ ==> Caveats Upgrading from MySQL <8.4 to MySQL >9.0 requires running MySQL 8.4 first: - brew services stop mysql - brew install [email protected] - brew services start [email protected] - brew services stop [email protected] - brew services start mysql We've installed your MySQL database without a root password. To secure it run: mysql_secure_installation MySQL is configured to only allow connections from localhost by default To connect run: mysql -u root To restart mysql after an upgrade: brew services restart mysql Or, if you don't want/need a background service you can just run: /opt/homebrew/opt/mysql/bin/mysqld_safe --datadir\=/opt/homebrew/var/mysql ==> Analytics install: 52,958 (30 days), 178,060 (90 days), 559,619 (365 days) install-on-request: 52,905 (30 days), 177,876 (90 days), 558,518 (365 days) build-error: 616 (30 days) \W $ 

The important bit was:

==> Caveats Upgrading from MySQL <8.4 to MySQL >9.0 requires running MySQL 8.4 first: - brew services stop mysql - brew install [email protected] - brew services start [email protected] - brew services stop [email protected] - brew services start mysql 

So i just followed those exact steps and I no longer encountered that error when running brew services start mysql

Note: While installing version 8.4 i also ran these commands too that come whiles installing mysql8.4 (VIA BREW)

If you need to have [email protected] first in your PATH, run: echo 'export PATH="/opt/homebrew/opt/[email protected]/bin:$PATH"' >> ~/.zshrc For compilers to find [email protected] you may need to set: export LDFLAGS="-L/opt/homebrew/opt/[email protected]/lib" export CPPFLAGS="-I/opt/homebrew/opt/[email protected]/include" For pkg-config to find [email protected] you may need to set: export PKG_CONFIG_PATH="/opt/homebrew/opt/[email protected]/lib/pkgconfig" 

If anyone is using brew, hope this helps.

Comments

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

works for me.

Comments

0

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.

Comments

0
$ sudo mysql.server restart 

It works for me.

Comments

0

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

cd /usr/local/Cellar sudo chown _mysql mysql 

Comments

0

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.

1 Comment

This worked for me. Please try this before doing anything else.
0

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.

Comments

0

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!

Comments

0

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.

1 Comment

This was also my issue, I was switching from MariaDB to MySQL. But switching back to MariaDB wasn't an acceptable solution. I removed the new mysql brew uninstall [email protected] then deleted the old mysql folder created by MariaDB sudo rm -rf /usr/local/var/mysql (this will delete your databases obviously). Then brew install [email protected] and mysql.server start and it works.
0

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

Comments

0

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

mysql.server status 

1 Comment

I've always solved this deleting the log files, but ps did in fact show mysql processes. I killed everything re-ran mysql.server restart and it worked!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.