MySql server startup error ‘The server quit without updating PID file ‘

The Question :

295 people think this question is useful

On Snow Leopard, starting MySQL gives the following error:

The server quit without updating PID file

my.cnf

[mysqld]
port            = 3306

socket          = /tmp/mysql.sock

skip-external-locking

key_buffer_size = 16K

pid-file=/var/run/mysqld/mysqld.pid

[mysqld_safe]

log-error=/var/log/mysqld.log

pid-file=/var/run/mysqld/mysqld.pid

The Question Comments :
  • running as admin user. with sudo /usr/local/mysql/support-files/mysql.server start
  • same problem. Installed mysql with brew
  • same problem here. also installed with brew.
  • I got this case too on my mac, and just removed the error log, like ‘/usr/local/var/mysql/*.err’, started successfully.
  • I also got same error on mac. But i got solved it. If you are installed via .dmg file go to system preferences then click on mysql icon then click start mysql button .

The Answer 1

289 people think this answer is useful

try to find your log file with suffix “.err”, there should be more info. It might be in:

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

It’s probably problem with permissions

  1. check if any mysql instance is running

    ps -ef | grep mysql

    if yes, you should stop it, or kill the process

    kill -9 PID

    where PID is the number displayed next to username on output of previous command

  2. check ownership of /usr/local/var/mysql/

    ls -laF /usr/local/var/mysql/

    if it is owner by root you should change it mysql or your_user

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

The Answer 2

201 people think this answer is useful

Did you follow the instructions from brew install mysql?

Set up databases to run AS YOUR USER ACCOUNT with:

For mysql 5.x:

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

To set up base tables in another folder, or use a different user to run mysqld, view the help for mysqld_install_db:

mysql_install_db --help

and view the MySQL documentation:

For mysql 8.x:

unset TMPDIR
mysqld --initialize-insecure --log-error-verbosity --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp

Make sure the data directory /usr/local/var/mysql above is empty, backup it if necessary.

To run as, for instance, user “mysql”, you may need to sudo:

sudo mysql_install_db ...options...

Start mysqld manually with:

mysql.server start

Note: if this fails, you probably forgot to run the first two steps up above

The Answer 3

125 people think this answer is useful

I had the same issue on my Mac machine (correctly followed all the installation steps suggested by brew install).

Deleting the error file fixed it for me:

sudo rm -rf /usr/local/var/mysql/dev.work.err (dev.work is my hostname)

This worked because dev.work.err was owned by _mysql:wheel instead of my own username. CHOWN-ing the error file would have probably fixed it as well.

The Answer 4

96 people think this answer is useful

After rebooting I had the same issue. Here is how I fixed it:

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

The Answer 5

33 people think this answer is useful

This worked for me…

Check all of the MySQL processes running:

$ ps aux | grep mysql

USER     PID    %CPU  %MEM 
_mysql   5970   0.0   0.4 ...

Then kill all the processes listed from the above command using the following:

$ sudo kill -9 [PID]

Replace [PID] with the individual PID from the list above, e.g. 5970.

Do that for all of the lines you see with the first command.

Then you can startup your MySQL server again:

mysql.server start

The Answer 6

26 people think this answer is useful

This error can occur when trying to start msql after it was improperly shutdown.

  1. Take a look at the mysql error log file. If it mentions something like “Check that you do not already have another mysqld process using the same data or log files.”, then you need to properly shutdown that process.

  2. See what process mysql is running on, use this command: lsof -i:3306

Your output should look like this:

COMMAND  PID    USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
mysqld  4249 username   17u  IPv4 0x7843d9d130469c0b      0t0  TCP localhost:mysql (LISTEN)

  1. Terminate the process running mysql: kill -15 4249

Kill -15 sends a siganl to the process to free up any resources it is locking and terminate the process after.

  1. Now mysql should startup with no problems: mysql.server start

The Answer 7

25 people think this answer is useful

Try to remove ib_logfile0 and ib_logfile1 files and then run mysql again

rm /usr/local/var/mysql/ib_logfile0
rm /usr/local/var/mysql/ib_logfile1

It works for me.

The Answer 8

24 people think this answer is useful

My error file told me also that the port may be being used by another process, but simply running sudo mysql.server start fixed the issue for me.

The Answer 9

19 people think this answer is useful

If no one answer helped you, just remove folder /usr/local/var/mysql and then install mysql again brew reinstall mysql.

The Answer 10

15 people think this answer is useful

I recently came across this issue, however it was working before, then stopped.

This was because I initially started mysql.server as root instead of myself.

The fix was to delete the err log file (which was owned by _mysql). Starting it again got it passed.

The Answer 11

12 people think this answer is useful

For me the fix was simple:

top

showed that mysqld was already running

sudo killall mysqld 

then allowed the process to start

The Answer 12

11 people think this answer is useful

For me I had to reinstall mysql

brew reinstall mysql

and then below To have launchd start mysql now and restart at login:

brew services start mysql

The Answer 13

10 people think this answer is useful

The solution that worked for me was here: https://serverfault.com/questions/334284/cant-create-pid-file-on-mysql-server-permission-denied

Changing some of my permissions seemed to do the trick. I’m running a Mid-2012 Macbook Air with OS X 10.8.2 and mysql was installed with homebrew.

chmod 0755 /var
chown root:wheel /var/tmp
sudo chmod 0771 /usr/local/var/mysql/*

The Answer 14

8 people think this answer is useful

I had this problem while trying to brew upgrade on MacOS X 10.7.5.

Unfortunately mysql was also upgraded to 5.6.10 from 5.5.14. Tried the new, did not work.

I decided to go back to my old setup and did a

brew switch mysql 5.5.14

This did not solve the problem. Elsewhere I read and did this, voila! All was back 🙂

cd /usr/local/var/mysql
mv ib_logfile0 ib_logfile0.bak
mv ib_logfile1 ib_logfile1.bak

The Answer 15

7 people think this answer is useful

I’m using,

I Installed MySQL using homebrew (‘brew install mysql’). It installed a couple of dependencies and then mysql.

When I tried to start it up,

west$ mysql.server start
Starting MySQL
.. ERROR! The server quit without updating PID file (/usr/local/var/mysql/west.local.pid).

I ran this command,

west$ /usr/local/Cellar/mysql/5.5.25/scripts/mysql_install_db 

and MySQL works.

Please take note that you need to run mysql_install_db from the with top level of the mysql directory (IE, usr/local/Cellar/mysql/5.5.25). Running it directly within the /scripts directory does not give it enough context for it to run.

The Answer 16

7 people think this answer is useful

For me the solution was to override/correct the data directory in /etc/my/cnf.

I built MySQL 5.5.27 from source with the directions provided in the readme file:


# Preconfiguration setup
shell> groupadd mysql
shell> useradd -r -g mysql mysql
# Beginning of source-build specific instructions
shell> tar zxvf mysql-VERSION.tar.gz
shell> cd mysql-VERSION
shell> cmake .
shell> make
shell> make install
# End of source-build specific instructions

# Postinstallation setup
shell> cd /usr/local/mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data

# Next command is optional
shell> cp support-files/my-medium.cnf /etc/my.cnf
shell> bin/mysqld_safe --user=mysql &

# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server


mysqld_safe terminated itself without explanation. running /etc/init.d/mysql.server start resulted in the error:

“The server quit without updating PID file”

I noticed something odd in the installation instructions though. It has ownership changed to mysql for the directory “data”, but not to “var”; this is unusual because for years I have had to ensure that var directory was mysql writable. So I manually ran chown -R mysql /usr/local/mysql/var and then attempted to start it again. Still no luck. But worse, no .err file in the var dir – it was in the “data” dir! so scripts/mysql_install_db sets up camp in /usr/local/mysql/var, but the rest of the application seems to want to do its work in /usr/local/mysql/data!

So I just edited /etc/my.cnf and under the section [mysqld] I added a directive to explicitly point mysql’s data directory to var (as I normally expect it to be any how), and after doing so, mysqld starts up just fine. The directive to add looks like this:

datadir = /usr/local/mysql/var

Worked for me. Hope it helps for you.

The Answer 17

6 people think this answer is useful

If your system has multiple version of Mysql then you are likely going to hit this PID error

we can begin with killing all MySQL process
sudo killall mysqld

Go to /usr/local choose which MySQL version you want to have, then provide the MySQL permission to that. In my case I needed version 8.
sudo chown -R mysql mysql-8.0.21-macos10.15-x86_64

Go to the folder /usr/local/mysql-8.0.21-macos10.15-x86_64 & start SQL server
sudo ./mysql.server start(Enter your laptop password) If it gives below output… the PID issue is solved

@xxxx-M-R0SU support-files $ sudo ./mysql.server start Starting MySQL .. SUCCESS!

The Answer 18

5 people think this answer is useful

It seems that MySQL process is running hence you are unable to use the port. You can check the running MySQL process using following command:

ps auxf | grep mysql

If you get any MySQL process kill that process ID using kill -9 PID and then try to start MySQL.

The Answer 19

5 people think this answer is useful

Start Mysql in safe mode

/usr/local/mysql/bin/mysqld_safe start

OR

on MAC End any mysql or mysqld task (or other) in your Activity Monitor application.

or check you error by

tail -f /usr/local/mysql/data/XXXXX-XXXXX-Pro.local.err

The Answer 20

4 people think this answer is useful

What’s the error log say? I got this error, and it ended up being an old invalid setting in the my.cnf, which the mysql error log indicated. If not a bad config setting, the error log should at least point you in the right direction.

Well, I assume the OP has fixed it at this point… but hopefully this points the others seeing this error in the right direction.

The Answer 21

4 people think this answer is useful

Somehow I screwed up my permissions on El Capitan and decided to reinstall MySQL from scratch.

I use brew on el capitan, and decided to reinstall:

brew uninstall mysql
sudo rm -rf /usr/local/var/mysql
brew install mysql
mysql.server start # ... SUCCESS

The file permissions on fresh install changed from _mysql to include my username

› ls -alh /usr/local/var/mysql
drwxr-xr-x   22 lfender  admin   748B Mar 22 09:58 .
# ... etc

The Answer 22

4 people think this answer is useful

With the help of a few answers posted here, I was able to find the issue

First I run

sudo -i

So I could have root access.

Than I deleted the xxxx.err file

rm -rf /usr/local/mysql/data/xxxx.err

after I started MySQL in SafeMode

/usr/local/mysql/bin/mysqld_safe start

It will try to start and will exit because of an error… a new xxx.err file will be created and you need to read it to see the cause of the error

tail -f /usr/local/mysql/data/mysqld.local.err

On my case, for some reason, it was missing some folder and file inside /var/log/ folder… So I created both

cd /var/log

mkdir mysql

touch mysql-bin.index

After the new file was created, than you need to change permission

chown -R _mysql /var/log/mysql

When all those steps where taken, my database started working immediately…

Hope this can help others here… The key is to read the error and log and find whats is wrong…

The Answer 23

4 people think this answer is useful

In my case, the error happens due to the accessing problem of the error log file.

The following two commands help me address the problem.

sudo chown <user> /usr/local/var/mysql/<my-host-name>.err
sudo chmod 666 /usr/local/var/mysql/<my-host-name>.err

The Answer 24

4 people think this answer is useful

This worked for me:

On a Mac with Homebrew:

List all instances of mysql that exists by running

$ brew services

Remove each instance by running

$ brew uninstall <instance_name>

Delete Mysql directory in /usr/local/var/mysql:

$ rm -rf /usr/local/var/mysql

Reinstall mysql using homebrew:

$ brew install mysql
$ brew install mysql@<version> #Optional

Rerun mysql.server start

$ mysql.server start

The Answer 25

3 people think this answer is useful

I hope this work for you.

After checking the error log, I found this:

120309 17:42:49 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
120309 17:42:50 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/mysql/data/ is case insensitive
120309 17:42:50 [Warning] You need to use --log-bin to make --binlog-format work.
120309 17:42:50 [Note] Plugin 'FEDERATED' is disabled.
120309 17:42:50 InnoDB: The InnoDB memory heap is disabled
120309 17:42:50 InnoDB: Mutexes and rw_locks use GCC atomic builtins
120309 17:42:50 InnoDB: Compressed tables use zlib 1.2.3
120309 17:42:50 InnoDB: Initializing buffer pool, size = 16.0M
120309 17:42:50 InnoDB: Completed initialization of buffer pool
120309 17:42:50  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 /usr/local/mysql/data/ib_logfile0
InnoDB: File operation call: 'open'.
InnoDB: Cannot continue operation.
120309 17:42:50 mysqld_safe mysqld from pid file /usr/local/mysql/data/lu1s.local.pid ended

And to solve it, I gave ownership rights to the entire mysql folder:

cd /usr/local
sudo chown mysql mysql
sudo chown mysql mysql-5.5.21-osx10.6-x86_64
sudo chown _mysql mysql
sudo chown _mysql mysql-5.5.21-osx10.6-x86_64

Then (you can do it command-line too), I applied the permissions (once I gave that ownership to _mysql and mysql users) to all enclosed folders from within the “get info” menu of the folder at /usr/local/mysql-5.5.21-osx10.6-x86_64 . You don’t need to tho that to the alias since it’s only an alias.

The name of the folder depends of the installation version of mysql that you have.

The Answer 26

3 people think this answer is useful

I had the same problem. moving my /etc/my.cnf file worked for me. I got the information here

The Answer 27

3 people think this answer is useful

Had the same issue, for me it was doing a brew remove while having a previous install of the mysqld running. Seems brew does not stop a service before uninstalling.

After checking the .err file i saw the logged error that another copy of mysql may be running, after terminating the old service. I was then able to restart the new mysql install.

The Answer 28

3 people think this answer is useful

Simple….

Fix the 2002 MySQL Socket error

Fix the looming 2002 socket error – which is linking where MySQL places the socket and where OSX thinks it should be, MySQL puts it in /tmp and OSX looks for it in /var/mysql the socket is a type of file that allows mysql client/server communication.

sudo mkdir /var/mysql

sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock

Well Done : )

This Help me A LOT! i took this guide from the guys on http://coolestguidesontheplanet.com/

The Answer 29

3 people think this answer is useful

Try this..

  1. Navigate to the problem’s parent directory cd YOURPATH/usr/local/mysql
  2. rm -rf *.local.err (deletes file)
  3. touch YOURUSERNAME.local.pid (generates new *.local.pid file the error thrown was complaining about)
  4. cd back into your project and restart mysql using mysql.server start

The Answer 30

2 people think this answer is useful

Check if you have space left in your drive. I got this problem when no space left in my drive.

Tags:

Add a Comment