MySQL server startup error 'The server quit without updating PID file'
Asked Answered
G

56

328

On Mac OS X v10.6 (Snow Leopard), starting MySQL gives the following error:

The server quit without updating PID file

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
Gentry answered 10/2, 2011 at 21:51 Comment(9)
How are you starting mysql? Does the user mysql is running as have read/write access to your /var/run/mysql/ folder?Hemoglobin
running as admin user. with sudo /usr/local/mysql/support-files/mysql.server startGentry
same problem. Installed mysql with brewBurtie
same problem here. also installed with brew.Varese
I got this case too on my mac, and just removed the error log, like '/usr/local/var/mysql/*.err', started successfully.Rancell
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 .Bertrand
on clicking the mysql start mysql button via system preferences pane, it doesnt start for some reasonRustle
One mac, there are a variety of issues that could be the reason for this error. You can find a step by step summary to solve them here: medium.com/@7anac/…Alizaalizarin
For my mac OS brew installed mysql following works: sudo chown -R $USER /usr/local/var/mysql then mysql.server startMousse
P
308

Try to find your log file with suffix ".err". There should be more information. It might be in:

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

It's probably a 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 the username on the output of the 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 to mysql or your_user

    sudo chown -R mysql /usr/local/var/mysql/
    
Parathion answered 15/11, 2011 at 13:56 Comment(15)
I had to chown to mysql user rather than my user.Nodarse
worked for me. i checked the error file and said that it was becuase o file permissions. executed the chown command and worked. thanks!!Idolatry
sudo chown -R my_user /usr/local/var/mysql/ worked for me at leastSanskritic
From my own experience - Be careful that after you've done the sudo chown that you don't currently have some mysql processes running under another user or root. ps -ef | grep mysql will validate that you have nothing running - otherwise you won't be able to start it.Som
sudo chown -R mysql /usr/local/var/mysql/ this worked like a charm for me.Pancake
The reason this was useful for me was that I was not able to control mysql from the native install. I installed via Homebrew instead, then was able to use this answer to kill all other (zombie) processes left over by Xampp. Thanks!Brubaker
+1 for mentioning permissions. For me it was chown -R mysql:mysql /var/lib/mysql (on Linux not Mac)Impurity
Mysql failed to start after I migrated it to a new machine. The chown command fixed it. I had to migrate to a new id on the destination machine. The change in the id most likely caused the problem.Ern
chown to myself fix the pid problem.Tracery
killing the process via kill -9 PID worked for me, thanksFragmental
This worked for me. In my case it was caused by running "sudo mysql.server start" instead of mysql.server start. This changed the owner of the pid file (mentioned in the error message) to _mysql. I noticed that every other file in there was owned by me, so I simply changed the owner of the PID file to myself and ran "mysql.server start".Donnettedonni
this line is what worked for me: "sudo chown -R mysql /usr/local/var/mysql/" it had been set to root. I'm not sure how it was changed but possibly by a different development environment I had recently set up locally.Woolsey
Total life saver. My only observation is the file path to mysql folder may vary.Renal
The chow helped me1Megillah
For me, it was caused by a permissions problem, but not file owner, selinux=enforcing try sudo setenforce 0Bushore
B
209

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. Back it up 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

Broadbill answered 16/6, 2012 at 6:57 Comment(16)
I also had to run the following two commands: You should reload mysql: launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plistCarolecarolee
If you're repeatedly getting the same error even after following the steps from the output then delete the *.err file from the same directory as the *.pid file. mahdiyusuf.com/post/21022913180/…Earleneearley
madebyhoundstooth.com/blog/… this is also a good reference.Dich
I tried following these instructions a million times but never got it to work. I tried to "cheat" by not cleaning up all the things brew doctor warned me about since I thought they didn't make a difference. In the end, cleaning up and following brew doctors advice made it possible to run through the setup described above. So a note to anyone else passing by; don't try to cheat the brew doctor and think you know better!Parturient
I still have a bunch of things wrong in when I brew doctor and adding write permission to my own user did the trick. sudo chown -R your_user /usr/local/var/mysql/ just as @Parathion 's answer :)Empty
FYI doesn't work on Mavericks using brew and Mysql Ver 14.14 Distrib 5.6.16Coffeng
If the setups above is not working. Please trying deleting the .err file (but in the same terminal session) then run the mysql.server start commandMadel
It might be important to back up your db, clear out all older MySQL versions you currently have and follow the install directions here coderwall.com/p/os6woq which also coincides with this solution.Coppinger
I had this problem as well, but the solution in this answer did not work. Ultimately, the only thing that worked was the answer a bit farther down, namely deleting the error file /usr/local/var/mysql/<yourcomputername>.local.errFabrication
@countfloortiles Yes! Removing the error file did it. :-)Harijan
The mysqld_install_db command gives me the error mysql_install_db: [ERROR] unknown variable 'tmpdir=/tmp'Delaryd
Correct answer? Not necessarily. If the problem is related to permissions, they can have changed because another operation that doesn't have relation with the mysql installation. The question isn't about installation.Vey
@Broadbill (mysql_install_db --verbose --user=sudo's login --basedir="/a/.../mysql_x" --datadir="/a/.../mysql_x/data" --tmpdir="/tmp") ; I am not sure does paths should have double quotes "path" for example? And it will be ok if to set path to another volume non-home one? After reboot I am facing pid file error as well right now X( Does it worth to create another mysql user as official readme says or using sudo for everything is pretty fine? Please give me a tipPoteet
@TaylorFoster allow me to disagree. The command fails mysql_install_db: [ERROR] unknown variable 'tmpdir=/tmp' tried running ` mysql_install_db --verbose --user=whoami --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir="/tmp"`Lydie
mysql_install_db is removed in mysql 8.0Gawen
/usr/local/mysql/support-files/mysql.server restart worked for meReactor
D
125

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.

Dynamic answered 25/3, 2013 at 9:46 Comment(9)
This solved my problem too, after rebooting mysql couldnt working anymore, giving me this same issue, but removing the error log which was owned by _mysql:admin solved the issueRutile
This seemed to be the most helpful, made me realize that I should not be starting this service with SUDO but running it under my own user account.Everetteeverglade
This is a pretty good answer for those who have installed MySQL using HomebrewSecretin
After weeks of trying different things, when I removed the error file everything started working. ThanksProtector
I didn't have to delete it, just chown it back to my account, because somewhere _mysql account took it over.Quern
This was the issue for me as well. Thanks.Jorie
OMG! some sort of unable to write to /path/to/errorlog.err output would be way to much to ask.Groveman
Worked perfectly for me!Prolactin
I tried many things and this was the first one to work for me. This is good if you previously had mysql installed and reinstalled it, since that file was owned by the previous installation of mysql.Querist
M
105

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

sudo chown -R _mysql /usr/local/var/mysql
Mouflon answered 23/8, 2013 at 14:15 Comment(8)
thanks a lot - don't forget to backup stuff though, just in case you're messing w/ the permissionsToolis
Thanks. I was having an issue with Lampp in Ubuntu. I copied the entire lampp folder from /opt to a new server. When I tried to start up mysql I got a message: The server quit without updating PID file. Go to lampp/var/ and do chown -R mysql mysql/ That worked for me!Meiosis
On El Capitan this worked: sudo chown -R _mysql /usr/local/mysql/dataValuate
@Justin; this answer also worked on El Capitan for meGerrald
@Valuate i recovered my password to vote your answer on El Capitan!Palaeontography
This didn't work for me. It just inserted a lot of permission denied errors, like this one: /usr/local/Cellar/[email protected]/5.7.23/bin/mysqld_safe: line 144: /usr/local/var/mysql/Victors-MacBook-Air-2.local.err: Permission deniedFabrikoid
/tmp/ folder - mysqlx.sock* files getting created with 'mysql' as a owner it worked for me after deleting those entriesIndemnity
note that if you installed using homebrew, command should be: sudo chown -R _mysql /opt/homebrew/var/mysqlSextans
G
35

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
Gussi answered 27/11, 2014 at 22:11 Comment(2)
or use pkill mysql to kill all processes that match "mysql" (-9 is unnecessary in most cases).Pamplona
to killall process with specific ID and start it againNikolos
L
35

Try to remove the 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.

Louanne answered 1/6, 2018 at 5:40 Comment(5)
I also removed the .err file in the same directory, which worked for me.Lawn
Well. This is dead simple and really works for me. But, in my case, I only renaming it to ib_log*.bakDespiteful
it worked for me, tried all other solutions, nothing worked, it worked after removing ib_logfile* files.Morlee
Nice solution , the other answers couldn't help meScreak
OMG! THIS WORKED FOR ME ALSO! This would have been the 3rd time when I would lost all of my dbs ! Thank you so much!Lathan
S
31

This error can occur when trying to start MySQL after it was improperly shut down.

  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 the command lsof -i:3306 (the default port number for MySQL is 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)
    
  3. Terminate the process running mysql: kill -15 4249

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

  4. Now MySQL should start up with no problems: mysql.server start

Scleroprotein answered 28/1, 2016 at 19:57 Comment(4)
This still works for me in High Sierra, for whatever that's worth.Ludlow
The lsof command may require sudo: sudo lsof -i:3306. Otherwise, the output may be empty.Axis
I have been researching for hours. NONE of the solutions worked, except this one. One of the reasons it didn't work earlier for me is that I didn't think I needed to disconnect from my remote server (via ssh tunnel) to clear the error. But when I finally gave up and closed my ssh tunnel to the remote server, the issue resolved itself.Southernly
I could not find the PID using ps -ef | grep mysql as stated above, but this one worked for me, thanks!Dekker
L
29

⚠️ This will erase your data, so make sure it's backed up first.

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

Louanne answered 7/2, 2018 at 2:22 Comment(4)
WARNING thats means erase all databases.Haar
I install a higher version mysql before, than I install mysql5.7 and this problem occurs. Just remove /usr/local/var/mysql and brew reinstall [email protected] solve it.Pelf
Move the dbs under /usr/local/var/mysql to another folder first. After installation and start mysql service successfully, try to move needed db back.Flavopurpurin
After trying several ways, this answer works for me. Removing /usr/local/var/mysql folder and reinstall mysql via brew works.Hypersensitive
C
24

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.

Capricorn answered 12/12, 2013 at 18:48 Comment(2)
yeah... this worked for me too... and nothing above workedTlaxcala
I was following instructions I'd read somewhere the way to start MySQL on a Mac is 'sudo /usr/local/mysql/support-files/mysql.server start'. That produced the error "the server quit without updating pid file", and that's how I got to this page. After trying numerous answers, I found 'sudo mysql.server start', and it worked. Thanks.Fossick
L
19

For me the fix was simple.

top

showed that mysqld was already running.

sudo killall mysqld 

then allowed the process to start.

Lois answered 7/1, 2016 at 18:18 Comment(2)
This answer is still helpful up to date.Jamikajamil
@Jamikajamil agreed! Thank you Luke MadhangaSwum
P
16

For me I had to reinstall MySQL:

brew reinstall mysql

And then the below to have launchd start MySQL now and restart at login:

brew services start mysql
Paviour answered 7/5, 2018 at 8:55 Comment(0)
L
15

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.

Loria answered 3/10, 2013 at 17:46 Comment(1)
Thanks! I had the same issue searching for an hour then came across your answer.Gwenora
S
11

The solution that worked for me was here: Can't 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 Mac OS X v10.8.2 (Mountain Lion) and MySQL was installed with Homebrew.

chmod 0755 /var
chown root:wheel /var/tmp
sudo chmod 0771 /usr/local/var/mysql/*
Scorcher answered 28/1, 2013 at 21:20 Comment(0)
S
9

This worked for me:

Note: This a hard reinstall. Use when all other options have been exhausted.

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 the 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
Sennit answered 31/5, 2020 at 2:25 Comment(2)
Just be warned, this approach is a hard re-install. This way will wipe out all your old databases.Iddo
This is very bad solutionNebuchadnezzar
A
8

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,

mysql.server start

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

I ran this command,

/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 top level of the MySQL directory (e.g., usr/local/Cellar/mysql/5.5.25). Running it directly within the /scripts directory does not give it enough context for it to run.

Andante answered 21/6, 2012 at 0:22 Comment(1)
Worked for me with 5.5.28 and brew on OSX 10.7.5Cognate
I
8

I had this problem while trying to brew upgrade on Mac OS X v10.7.5 (Lion).

Unfortunately MySQL was also upgraded to 5.6.10 from 5.5.14. I tried the new version, but it 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
Isis answered 19/2, 2013 at 22:28 Comment(1)
This worked for me after first using brew upgrade mysql and then brew switch mysql 5.7.17 which was my previous version. Weird!Feast
M
8

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.

Then 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

In 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, then you need to change permissions:

chown -R _mysql /var/log/mysql

When all those steps were taken, my database started working immediately...

The key is to read the error and log and find what's is wrong...

Malony answered 18/8, 2016 at 17:34 Comment(0)
O
7

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.

Oblong answered 12/8, 2012 at 7:38 Comment(0)
M
7

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 processes:

sudo killall mysqld

Go to /usr/local and choose which MySQL version you want to have, and 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 and start the SQL server:

sudo ./mysql.server start (Enter your laptop password)

If it gives the below output... the PID issue is solved

sudo ./mysql.server start

Starting MySQL
.. SUCCESS!
Mathew answered 13/8, 2020 at 16:11 Comment(0)
T
5

It seems that the 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.

Thousandfold answered 8/7, 2013 at 20:0 Comment(1)
This answer is my savior.Numismatics
S
5

Start MySQL in safe mode:

/usr/local/mysql/bin/mysqld_safe start

Or on the 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
Separatrix answered 9/9, 2015 at 3:12 Comment(0)
T
4

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

Twicetold answered 11/11, 2011 at 3:36 Comment(0)
L
4

Somehow I screwed up my permissions on Mac OS X v10.11 (El Capitan) and decided to reinstall MySQL from scratch.

I use Homebrew 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 a 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.
Ligon answered 22/3, 2016 at 14:6 Comment(1)
Warning: this will erase your databases, make sure they're backed upOutwardly
C
4

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
Cocks answered 6/7, 2016 at 10:27 Comment(0)
P
3

I hope this works 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.

Politi answered 10/3, 2012 at 2:0 Comment(0)
S
3

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

Sheep answered 5/1, 2013 at 13:33 Comment(0)
I
3

I had the same issue. For me it was doing a brew remove while having a previous install of the mysqld running. It seems Homebrew (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.

Ionone answered 6/6, 2013 at 11:53 Comment(2)
Yes, check error logs. In my case, I ran ls -latr /usr/local/var/mysql/ to find the latest modified file, which included the error log, then tail -50 name.err to see the error, which was a problem in config.Thunderous
thanks god, you were right. I used ps aux | grep mysqld and then terminated the process with kill -9 [proccessid] and the server started successfullyFancher
H
3

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

Hoagland answered 29/11, 2013 at 11:39 Comment(1)
I would have never thought about the space problem had you not mentioned. You're a saviour!Infectious
T
3

Simple...

Fix the 2002 MySQL socket error.

Fix the looming 2002 socket error – which is linking where MySQL places the socket and where OS X thinks it should be. MySQL puts it in /tmp and OS X 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 helped me a lot!

I took this guide from the guys on http://coolestguidesontheplanet.com/

Total answered 25/10, 2014 at 18:48 Comment(0)
G
2

The problem is a permissions one. It can't start because it can't write to file mac.err because it’s owned by someone else.

Make sure the /usr/local/var/mysql folder is owned by the user that will start MySQL. If I start MySQL as jack it’s all good. However, if you start it as root, it will create a mac.err file (owned by root) file that jack can't write to, so when you try to restart it as jack it will fail.

  1. Ensure the folder and files are owned by the user running mysql.server start
  2. Make sure there's not already a mac.err or mac.pid file owned by someone else.
  3. Start is as the right user.
Gyrostabilizer answered 21/1, 2015 at 13:28 Comment(1)
I used chown -R <user_name> /usr/local/var/mysql and it worked great. Nice solution.Capacitor
T
2

Move the log file named “ib_logfile” in “/var/lib/mysql” and restart mysql. Sometimes mysql will fail because it faces difficulty updating the log file

mv /var/lib/mysql/ib_logfile* /some/tmp/folder/

You can also remove ib_logfile as it will be created automatically after mysql restart

now restart mysql server

Tell answered 21/1, 2015 at 19:57 Comment(0)
M
2

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
Minnieminnnie answered 25/4, 2015 at 3:48 Comment(3)
This worked for me. Reason being, the error.log file was owned by "_mysql" throwing errors in the logs. Just wanted to log that incase anyone else has this issue. 150818 19:32:06 mysqld_safe Logging to '/opt/boxen/log/mysql/error.log'. 150818 19:32:06 mysqld_safe Starting mysqld daemon with databases from /opt/boxen/data/mysql /opt/boxen/homebrew/bin/mysqld_safe: line 129: /opt/boxen/log/mysql/error.log: Permission deniedRudolph
This doesn't work if your problem is related to permissions, that throws the same mysql error.Vey
Worked for me as well. I also had to restart my apache (for those also using a LAMP stack).Repetitious
S
2

In my case, I got this issue on a VPS and with cPanel.

I tried most of the previous answers, but without success.

  1. check where your error log is. It would be mentioned at the end of the error line.

    ERROR! The server quit without updating PID file (/var/lib/mysql/111318.vps-11.com.pid).

  2. Open that file (/var/lib/mysql/111318.vps-11.com.err) and check the bottom for the latest lines. In my case, there is

    [ERROR] Fatal error: Can't open and lock privilege tables: Table './mysql/db' is marked as crashed and should be repaired

  3. How solve this: Recovering and fixing the table indexes by command:

    [~]# myisamchk -r /var/lib/mysql/mysql/db.MYI

    MySQL is not running

  4. (Re)Start your MySQL server

Sprang answered 18/5, 2016 at 11:35 Comment(0)
S
1

I was trying to reinstall MySQL, and I actually forgot to stop the server from my old install. To solve that, ps -ax | grep mysql and kill [whatever PIDs]. But, then again, it's different for everybody. Like the other answers said, go to /usr/local/var/mysql/ and check your .err log file.

Seaman answered 26/1, 2013 at 2:16 Comment(1)
This was my problem also - in the log file I was getting "Unable to lock ./ibdata1 error: 35". Killed all processes > restart and SUCCESS!Jonjona
G
1

In my case, when I tried to start MySQL, I received the same error: The server quit without updating PID file. This is what I did to fix it (using Terminal):

goto /usr/local/var/mysql
sudo rm -rf hostname.err # Delete .err file
cd /usr/local/mysql/support-files
sudo mysql.server start # Success!
Goodyear answered 2/3, 2015 at 5:59 Comment(0)
G
1

Remove the pid file, then start up mysqld again.

Gothart answered 12/3, 2015 at 22:24 Comment(0)
H
1

Delete *.err files that you find in the directory displayed in the error, create the file MySQL is complaining about, and restart MySQL.

Holcombe answered 18/3, 2015 at 5:37 Comment(2)
It is ok after I remove error file then start server again: rm /usr/local/var/mysql/*.errChian
wtf? Why does the server die at startup when there's an old err-file?Consolute
V
1

I encountered this problem after a reboot and removing all *err files.

It appeared for me that the my.cnf.d directory was missing in folder /usr/local/etc.

It created it:

mkdir /usr/local/etc/my.cnf.d

And I just copy-pasted files my.cnf and my.cnf.default located in /usr/local/etc into that directory.

Then MySQL was able to restart:

cd /usr/local/var/mysql
mysql.server start

And MySQL works.

Vision answered 14/3, 2019 at 8:22 Comment(1)
WTF......all the error logs were leading to permissions....13 hours wasted and this is like JESUS to me...!!Katheykathi
G
0

This problem usually arrives when you do not have the libaio.1 library installed. Install that package first and redo the mysql_install_db step.

Download and then install the library using the following commands on the terminal from the folder where you extracted it.

make prefix=$HOME install
cd /usr/local/lib
ln -sv $HOME/libaio.so.1 libaio.so.1
Ghibelline answered 9/1, 2013 at 8:37 Comment(1)
Can you provide some more information? E.g., what is the full name of the library and what does it do (or is supposed to do)? Why is it necessary? Where are there some installation instructions and other information? Please respond by editing (changing) your answer, not here in comments (without "Edit:", "Update:", or similar - the answer should appear as if it was written today).Axis
B
0

It could be related to an old MySQL process. You need to kill it and restart. Sometimes it can be due to a conflict in a MySQL configuration file. Try to move it and restart MySQL.

Check the following URL for more details.

http://linuxadministrator.pro/blog/?p=225

Belgian answered 12/4, 2013 at 11:1 Comment(1)
The link is broken: "Hmm. We’re having trouble finding that site. We can’t connect to the server at linuxadministrator.pro."Axis
M
0

Disable SELinux in /etc/selinux/config:

SELINUX=disabled and restart the server.

Majestic answered 2/7, 2013 at 19:8 Comment(0)
F
0

I encountered this issue after swapping server IP addresses. The database was working fine before that. There was an entry in file /etc/my.cnf that I needed to update:

bind-address = xxx.xxx.xxx.xx

It had the old IP address in there.

Fuscous answered 14/4, 2014 at 15:53 Comment(0)
P
0

I had the same problem. The reason is quite simple. I installed two MySQL servers. One from MacPorts, and the other from a downloaded package. So I just followed the instruction here and uninstalled the one from the package.

How do you uninstall MySQL from Mac OS X?

After that, MySQL was working well.

Perionychium answered 1/8, 2014 at 19:37 Comment(0)
R
0

It’s a problem in the 5.5 version:

Here's an example for the [mysqld] section of your my.cnf file:

skip-character-set-client-handshake
collation_server=utf8_unicode_ci
character_set_server=utf8

Reference: 10.3.2 Server Character Set and Collation

Rotogravure answered 5/9, 2014 at 10:6 Comment(0)
A
0

I tried remove all the *.err files, but I am still getting the same error. I got one of the errors in error log:

[ERROR] InnoDB: Attempted to open a previously opened tablespace. Previous tablespace erp/brand uses space ID : 7 at filepath: ./erp/brand.ibd. Cannot open tablespace webdb1/system_user which uses space ID: 7 at filepath: ./webdb1/system_ user.ibd

So I deleted all the ib* files and it worked:

rm -f *.err ib*
Asa answered 30/3, 2015 at 4:23 Comment(2)
DONT DELETE Ib* FILES, if you do you will corrupt your InnoDB tables. I just did this and I'cant access my tables now, the real solution that worked to start mysql for me was fix permissions (chown files to user that run mysql)Alesiaalessandra
this fix my issue in MacOS Catalina.Vibes
T
0

On Mac OS X v10.9 (Mavericks), this script helped me:

bash <(curl -Ls http://git.io/eUx7rg)

And then I reset my password according with ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES).

Tympan answered 4/8, 2015 at 18:20 Comment(0)
W
0

In my case, the problem was, that the MySQL data directory was moved by accident to the wrong directory (/var/log, and not to /var/lib).

After moving the data back to /var/lib/mysql and restarting server, all everything went back to normal again.

Went answered 9/10, 2015 at 6:57 Comment(0)
M
0

In my Homebrew MySQL installation, I simply had to move the ib_logfile0 and ib_logfile1 located in /usr/local/var/mysql/ to a different directory.

Then I just did mysql.server start and everything worked.

Mydriatic answered 15/1, 2016 at 22:5 Comment(0)
E
0

I fixed this issue by running

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

Here myUserName is my current login username.

Expressage answered 1/1, 2021 at 10:11 Comment(0)
O
0

I have to examine my error file in safe mode to find the root cause:

  1. rm -f /usr/local/var/mysql/*.err
  2. mysqld_safe start
  3. cat mysql/*.err

That revealed an error in the upgrade routine. I tried to fix it, but I couldn't find enough information online. After that I gave up and manually exported the databases:

  1. mysql.server start --upgrade=MINIMAL, so the server will start
  2. mysqldump won't work because it will try to run the full upgrade, but you can use Sequel Pro, phpMyAdmin, etc. to export.
  3. Stop the server, rename the mysql folder to mysql.broken, and do a clean install to get a fresh mysql folder.
  4. Start MySQL, and manually import the .sql files you exported earlier.
Outwardly answered 3/3, 2021 at 22:7 Comment(0)
B
0

My answer is unprofessional and I do not understand it. I used CentOS and the generic version of MySQL... when I started the mysql with root user my problem solved using --user=root:

/path/to/mysql/support-files/mysql.server start --user=root

If you are using systemctl start mysql.service, you need to change the mysql.service file in /etc/systemd/system/mysql.service:

.
.
.
ExecStart=/path/tp/mysql/support-files/mysql.server start --user=root
ExecStop=/path/to/mysql/support-files/mysql.server stop --user=root
.
.
.
Botanize answered 9/3, 2021 at 17:44 Comment(0)
R
0

try with sudo rm -rf /usr/local/var/mysql/HOSTNAME.err (HOSTNAME is my hostname)

Rubicund answered 18/11, 2021 at 11:33 Comment(1)
Already mentioned in this answer and other ones.Corell
C
0

This is the simplest "PID" error's solution for MySQL Database in macOS:

  1. Run this command:
$ sudo mysql.server start
Starting MySQL
.. SUCCESS! 
  1. Access database with this command:
$ mysql -u root

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 19
Server version: 8.0.31 Homebrew

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
Database
information_schema
mysql
performance_schema
sys
4 rows in set (0.00 sec)
Cryometer answered 21/10, 2022 at 14:46 Comment(0)
U
0

On my system (macOS Ventura 13.6), the problem related to the upgradation. I got mysql and httpd start issue when it got shutdown unexpectedly.

First run below command on your mac and update/install any missing dependencies...

brew doctor

I have to install protobuf@21 by suggestion given by brew.

brew install protobuf@21

Then run below command and voila, mysql started successfully!

cd /usr/local/var/mysql 

mysql.server start 
Undersized answered 8/4 at 16:58 Comment(0)
L
-1

If you are running a MySQL Galera cluster, such as Percona XtraDB Cluster, check for wsrep_recovery.* files in the data directory (eg: /var/lib/mysql).

I was getting the same message from systemctl when trying to start a node which had been killed by the host's OOM killer, but there wasn't any indication of why the startup failed in any of the normal logs. The wsrep recovery files had the answer, and in my case I needed to start MySQL with the following flag:

mysqld --tc-heuristic-recover=ROLLBACK
Loydloydie answered 22/6, 2018 at 10:12 Comment(0)
R
-3
open /usr/local/var/mysql

You just remove the folder in Finder, and

brew install mysql

install again.

I've solved from this solution.

But this solution will delete your database.

Reader answered 2/3, 2016 at 2:27 Comment(3)
But that would also delete all of your local databases. Not really a perfect solution.Aerodrome
oh I've missed that. Thank you for adding the commentReader
On macOS presumably. Can you add information about versions to your answer, etc. (e.g., Mac OS X v10.11 (El Capitan))? (But without "Edit:", "Update:", or similar - the answer should appear as if it was written today.)Axis

© 2022 - 2024 — McMap. All rights reserved.