57

I am having an issue where MySQL isn't starting on my QNAP NAS.

I found this first by not being able to log in through phpMyAdmin - was getting error:

#2002 Cannot log in to the MySQL server

I then went to attempt to start mysql, as I guess this is a common issue with this, but it just gave a generic error.

I went through troubleshooting the mysql.sock file and everything, changing its permissions, but nothing is working.

I have rebooted my NAS many times.

I eventually tried to restart mysql. In doing so I get:

ERROR! MySQL manager or server PID file could not be found!

I can't find anything specific to the QNAP or any general type troubleshooting for this. Everything I find seems to be OSX related.

tshepang
  • 12,111
  • 21
  • 91
  • 136
adprocas
  • 1,863
  • 1
  • 14
  • 31
  • http://sysinfo.bascomp.org/mysql/error-mysql-manager-or-server-pid-file-could-not-be-found/ – Naveen Kumar Alone Jul 02 '13 at 11:53
  • That didn't fix it, but I did find out how to fix it. That suggestion is all over the place. As I said above, I went through troubleshooting the mysql.sock file and everything, but none of that worked. I'm going to answer my own question, so check the answer below. – adprocas Jul 02 '13 at 21:40

20 Answers20

74

After a lot of searching, I was able to fix the "PID file cannot be found" issue on my machine. I'm on OS X 10.9.3 and installed mysql via Homebrew.

First, I found my PID file here:

/usr/local/var/mysql/{username}.pid

Next, I located my my.cnf file here:

/usr/local/Cellar/mysql/5.6.19/my.cnf

Finally, I added this line to the bottom of my.cnf:

pid-file = /usr/local/var/mysql/{username}.pid

Hopefully this works for someone else, and saves you a headache! Don't forget to replace {username} with your machine's name (jeffs-air-2 in my case).

jeffwtribble
  • 1,131
  • 1
  • 9
  • 6
  • 37
    @adpro I know, just figured someone else in my shoes might stumble across this and appreciate the answer. :) – jeffwtribble Jan 02 '15 at 20:42
  • 1
    I also had to do a `sudo chown -R (whoami) /usr/local/var/mysql` followed by a `mysql.server restart`. – Vik Feb 21 '17 at 03:29
  • I'm running MariaDB which has a mysql_config file in "/usr/local/Cellar/mariadb/10.2.12/bin/mysql_config", where I added "pid-file = /usr/local/var/mysql/(my_computer_name).local.pid" at the bottom of that file but the .pid file is created dynamically and named according to which network I'm on, so adding the path with the .pid filename won't work. If there's this error, I can start up and shut down by killing any excess mysql process (there should only be one). – Dave Everitt Aug 15 '19 at 13:26
  • On OSX version 8 of MySQL puts the PID in /usr/local/mysql/data/mysqld.local.pid - You can look it up in the System Preferences MySQL configuration panel – Keith Whittingham Dec 20 '20 at 15:58
  • Thanks lot! Inspired by you, I found is .pid, and I recently changed the network my mac access in. So my hostname changed, and mysql cannot find the old hostname.pid file. After I change back my mac hostname in the router, `mysql.server stop` works! – Loyea Jan 03 '22 at 11:02
36

I tried everything above, but saw no results until I got a hint from here: https://superuser.com/questions/159486/how-to-kill-process-in-mac-os-x-and-not-have-it-restart-on-its-own

I eventually went over to the activity monitor in my Mac, force Quit the PID, and ran the command:

sudo /usr/local/mysql/support-files/mysql.server restart

The magic was done!!!

Community
  • 1
  • 1
Yoosaf Abdulla
  • 3,722
  • 4
  • 31
  • 34
31

If you have installed MySQL using brew the best way to go would be with homebrew

brew services restart mysql

after you run that command, all the problems that the update generated will be resolved

Alvaro Mena
  • 419
  • 4
  • 2
  • 3
    this works, but does not remove the error of `MySQL server PID file could not be found!` when running `mysql.server restart` – GMarx Nov 29 '16 at 05:34
  • 3
    got this error: `Error: Formula mysql is not installed.` – Adil Aug 18 '17 at 15:16
  • If you face this error `Error: Formula mysql is not installed.`. Try this -> Find which version of mysql is installed using `which mysql` and then mention the version in this command `brew services restart mysql@5.6` – Vignesh VRT Aug 20 '21 at 09:16
16

I ended up figuring this out on my own.

In searching for my logs I went into

cd /usr/local/mysql/var

In there I found the file named [MyNAS].pid (replace [MyNAS] with the name of your NAS.

I then ran the following to remove the file

rm -rf /usr/local/mysql/var/[MyNAS].pid

I then restarted mysql

[/usr/local/mysql/var] # /etc/init.d/mysqld.sh restart        
/mnt/ext/opt/mysql
/mnt/ext/opt/mysql
Try to shutting down MySQL
ERROR! MySQL manager or server PID file could not be found!
/mnt/ext/opt/mysql
Starting MySQL. SUCCESS! 

I tested everything and it all works like a charm again!

adprocas
  • 1,863
  • 1
  • 14
  • 31
6

Run the below commands and it will work.

Go to terminal and type

sudo chown -RL root:mysql /usr/local/mysql

sudo chown -RL mysql:mysql /usr/local/mysql/data

sudo /usr/local/mysql/support-files/mysql.server start
Single Entity
  • 2,925
  • 3
  • 37
  • 66
Shabeer
  • 59
  • 1
  • 2
  • 1
    I don't know how it works. I have never seen magic before... But It works! I just copied and pasted and put "SUCCESS"! Thank you, my hero! – aalexren Apr 10 '19 at 20:26
4

Just run mysqld (don't run as root) from your terminal. Your mysql server will restart and reset everything

And use a command like so:

mysql -u root -h 127.0.0.1
miken32
  • 42,008
  • 16
  • 111
  • 154
Adrian Cid Almaguer
  • 7,815
  • 13
  • 41
  • 63
2

ERROR! MySQL server PID file could not be found!

This might be due to issues with disk space, disk inode usage or innodb corruption which may lead to the error.

The issue was with the pid file and the solution was:

  1. SSH login to server as a root

  2. Create directory /var/run/mysql

mkdir /var/run/mysql

3) Create a file with name as mysqld.pid

touch mysqld.pid

  1. Change its ownership and group to mysql:mysql

    chown mysql:mysql mysqld.pid

  2. Restart MySQL service

Done!

Afrizal
  • 21
  • 2
1

I had the same issue. It turns out I added incorrect variables to the my.cnf file. Once I removed them and restarted mysql started with no issue.

1

Check if your server is full first, thats a common reason (can't create the PID file because you have no space). Run this to check your disk usage..

df -h

If you get something like this, you are full..

Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        40G   40G     0 100% /

In that case, you need to start looking for what to delete to make room, or add an additional drive to your server.

Luuk
  • 12,245
  • 5
  • 22
  • 33
P-Didz
  • 51
  • 2
1

Nothing of this worked for me. I tried everything and nothing worked.

I just did :

brew unlink mysql && brew install mariadb

My concern was if I would lost all the data, but luckily everything was there.

Hope it works for somebody else

Alejandro Giraldo
  • 609
  • 1
  • 6
  • 11
1

Note: If you just want to stop MySQL server, this might be helpful. In my case, it kept on restarting as soon as I killed the process using PID. Also brew stop command didn't work as I installed without using homebrew. Then I went to mac system preferences and we have MySQL installed there. Just open it and stop the MySQL server and you're done. Here in the screenshot, you can find MySQL in bottom of system preferences.enter image description here

Abhijeet Khangarot
  • 1,281
  • 1
  • 16
  • 25
0

I have the same problem. I found the file {username}.local.err instead of {username}.local.pid inside /usr/local/mysql, then i changed the name *.err to *.pid and it works fine.
Starting MySQL. SUCCESS!

My OS El Capitan 10.11.5

Community
  • 1
  • 1
phzao
  • 81
  • 1
  • 2
  • 9
0

I know this is an older post, but I ran into the ERROR! MySQL server PID file could not be found! when trying to start MySQL after making an update to my.cnf file. I did the following to resolve the issue:

  1. Deleted my experimental update to my.cnf

  2. Deleted the .net.pid and .net.err files.

delete /usr/local/var/mysql/**<YourUserName>**-MBP.airstreamcomm.net.*
  1. Ensured all MySQL processes are stopped.
ps -ax | grep mysql
kill **<process id>**
  1. Started MySQL server as normal.
mysql.server start
ggorlen
  • 44,755
  • 7
  • 76
  • 106
eleckctra
  • 1
  • 1
0

First find PID of mysql service

ps aux | grep mysql

Then, you have to kill process

 sudo kill <pid>

After you again start mysql service

mysql.server start
Turan Zamanlı
  • 3,828
  • 1
  • 15
  • 23
0

After doing setup of PHPMyAdmin, I was also facing the same problem,

Something . Like this

  • Then I just stopped the MYSQL server by going into System settings, and then started again, and it worked.
hardik chugh
  • 1,082
  • 15
  • 12
0
root@host [~]# service mysql restart
MySQL server PID file could not be found! [FAILED]
Starting MySQL.The server quit without updating PID file (/[FAILED]mysql/host.pxx.com.pid).

root@host [~]# vim /etc/my.cnf
Add Line in my.cnf its working know
innodb_file_per_table=1
innodb_force_recovery = 1

Result

root@host [~]# service mysql restart
MySQL server PID file could not be found! [FAILED]
Starting MySQL……….. [ OK ]
root@host [~]# service mysql restart
Shutting down MySQL…. [ OK ]
Starting MySQL. [ OK ]

Source

Victor S.
  • 2,510
  • 3
  • 22
  • 35
0

This is a solution to the following error occurring after an attempt to start mySQL server in Terminal:

ERROR! MySQL server PID file could not be found!

Starting MySQL

. ERROR! The server quit without updating PID file

This solution worked for me for mySQL version 8.0.18 on macOS Mojave 10.14.6.

SOLUTION

  1. Uninstall mySQL in System Preferences>Uninstall

  2. Remove leftover files as described here: https://community.jaspersoft.com/wiki/uninstall-mysql-mac-os-x

  3. Install mySQL again using dmg file. IMPORTANT: uncheck the button “Start mySQL upon the completion of this installation” (or something sounding like this).

  4. Important: BEFORE starting mySQL server for the first time, ensure you as a user have appropriate permissions. In Terminal, type the following commands (use your username instead of user):


sudo chown -RL user /usr/local/mysql

chmod 777 /usr/local/mysql

sudo chown -RL user /usr/local/mysql/data

chmod 777 /usr/local/mysql/data

sudo chown -RL user /usr/local/mysql/bin

chmod 777 /usr/local/mysql/bin

  1. Start mySQL server by typing the command


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

If you get the error



ERROR! MySQL server PID file could not be found!

Starting MySQL

. ERROR! The server quit without updating PID file (/usr/local/mysql/data/Users-MacBook-Pro.local.pid)



proceed as follows.


  1. Find the file /usr/local/mysql/data/Users-MBP.hitronhub.pid and open it in a text editor (there should be your user name instead of User in the name of the pid file). Your pid file may be under a different name, look for a pid file in /usr/local/mysql/data or wherever your mysql/data directory is housed. The path to the pid file may also be in the error message (see above).



Once you have located the pid file, open it in a text editor.

 If the OS system does not give you permission to read the pid file, use the commands

sudo chown -RL user /usr/local/mysql/data/Users-MBP.hitronhub.pid


chmod 777 /usr/local/mysql/data/Users-MBP.hitronhub.pid

(again, use your username instead of user/User)



Once you open the file, you should see a number. That number denotes the process that your OS is running mySQL under. Copy that number. Then kill that process by typing 


kill number

in Terminal.

  1. Start mySQL server by typing the command


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

At this point, it worked for me.

Good luck!

Lemonina
  • 712
  • 2
  • 14
oxi
  • 1
0

I had tried several of these solutions, but it wouldn't work.

 brew install mysql

After running this command I didn't do anything and all my original data came back online.

John Ballinger
  • 7,380
  • 5
  • 41
  • 51
-3

screenshot

If you're using MySQL Workbench, the mysql.server stop/restart/start will not work.

You will need to login into the workbench and then click "shutdown server". See image attached.

Vikrant
  • 4,920
  • 17
  • 48
  • 72
  • Unless things have changed or I am completely wrong, MySQL Workbench is just an IDE for MySQL. It may let you start and stop and connect to your MySQL server, but it is not the server, and the `stop/restart/start` will work if you actually do it on the server and not inside MySQL Workbench. In other words, the MySQL server is not dependent on MySQL Workbench, so `stop/restart/start` will not magically stop working because you're using MySQL Workbench. – adprocas May 24 '18 at 21:24
  • stop/restart/start does not work on mac when using the mysql workbench, it gives "ERROR: pid file not found" when using mysql workbench everything perfectly shutsdown. – John Karasev May 25 '18 at 20:26
  • Ok, MySQL Workbench might do something more. I don't know. But your answer indicates that if anyone uses MySQL Workbench, the commands mentioned will not work. I'm saying that your problem with those commands is not likely to do with MySQL Workbench. There's a possibility it holds on to something when the server is started using MySQL Workbench, so you may be correct, but it's important to not assume you know that using MySQL Workbench will always make it so those commands don't work. – adprocas May 26 '18 at 21:42
-4

I was able to solve this on OS X by shutting down the existing mysql.server that was running:

mysql.server stop

The starting:

mysql.server start

From there I could run mysql.server restart without throwing the ERROR.

Kevinleary.net
  • 8,851
  • 3
  • 54
  • 46
  • Again, the question was for a qnap nas, not OSX. – adprocas Jun 01 '16 at 11:03
  • This answer commonly comes up on search engines when searching for the same problem on OS X so I thought I would help out and post this for others that arrive here via search. "ERROR! MySQL manager or server PID file could not be found!" – Kevinleary.net Jun 02 '16 at 14:47