MySQL server startup error 'The server quit without updating PID file'
MysqlMysql Problem Overview
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
Mysql Solutions
Solution 1 - Mysql
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
-
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 -
Check ownership of
/usr/local/var/mysql/
ls -laF /usr/local/var/mysql/
If it is owner by
root
, you should change it tomysql
oryour_user
sudo chown -R mysql /usr/local/var/mysql/
Solution 2 - Mysql
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
Solution 3 - Mysql
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.
Solution 4 - Mysql
After rebooting I had the same issue. Here is how I fixed it:
sudo chown -R _mysql /usr/local/var/mysql
Solution 5 - Mysql
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
Solution 6 - Mysql
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.
Solution 7 - Mysql
This error can occur when trying to start MySQL after it was improperly shut down.
-
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.
-
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)
-
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.
-
Now MySQL should start up with no problems:
mysql.server start
Solution 8 - Mysql
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.
Solution 9 - Mysql
⚠️ 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
.
Solution 10 - Mysql
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.
Solution 11 - Mysql
For me the fix was simple.
top
showed that mysqld was already running.
sudo killall mysqld
then allowed the process to start.
Solution 12 - Mysql
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
Solution 13 - Mysql
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/*
Solution 14 - Mysql
I'm using
- a brand new MacBook Pro with OS X v10.7.3.x (Lion)
- GCC via the OS X GCC installer
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.
Solution 15 - Mysql
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
Solution 16 - Mysql
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.
Solution 17 - Mysql
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 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
Solution 18 - Mysql
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!
Solution 19 - Mysql
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.
Solution 20 - Mysql
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
Solution 21 - Mysql
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...
Solution 22 - Mysql
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.
Solution 23 - Mysql
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.
Solution 24 - Mysql
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
Solution 25 - Mysql
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.
Solution 26 - Mysql
I had the same problem. Moving my /etc/my.cnf file worked for me. I got the information here.
Solution 27 - Mysql
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.
Solution 28 - Mysql
Check if you have space left in your drive. I got this problem when no space left in my drive.
Solution 29 - Mysql
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/
Solution 30 - Mysql
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.
- Ensure the folder and files are owned by the user running
mysql.server start
- Make sure there's not already a mac.err or mac.pid file owned by someone else.
- Start is as the right user.
Solution 31 - Mysql
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
Solution 32 - Mysql
Try this...
- Navigate to the problem's parent directory
cd YOURPATH/usr/local/mysql
rm -rf *.local.err
(deletes file)touch YOURUSERNAME.local.pid
(generates new *.local.pid file the error thrown was complaining about)- 'cd' back into your project and restart MySQL using
mysql.server start
Solution 33 - Mysql
In my case, I got this issue on a VPS and with cPanel.
I tried most of the previous answers, but without success.
-
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).
-
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
-
How solve this: Recovering and fixing the table indexes by command:
> [~]# myisamchk -r /var/lib/mysql/mysql/db.MYI
-
(Re)Start your MySQL server
Solution 34 - Mysql
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.
Solution 35 - Mysql
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!
Solution 36 - Mysql
Remove the pid file, then start up mysqld again.
Solution 37 - Mysql
Delete *.err files that you find in the directory displayed in the error, create the file MySQL is complaining about, and restart MySQL.
Solution 38 - Mysql
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.
Solution 39 - Mysql
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
Solution 40 - Mysql
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.
Solution 41 - Mysql
Disable SELinux in /etc/selinux/config
:
SELINUX=disabled
and restart the server.
Solution 42 - Mysql
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.
Solution 43 - Mysql
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.
https://stackoverflow.com/questions/1436425/how-do-you-uninstall-mysql-from-mac-os-x
After that, MySQL was working well.
Solution 44 - Mysql
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
Solution 45 - Mysql
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*
Solution 46 - Mysql
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 https://stackoverflow.com/questions/21944936/error-1045-28000-access-denied-for-user-rootlocalhost-using-password-y/25883967#25883967.
Solution 47 - Mysql
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.
Solution 48 - Mysql
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.
Solution 49 - Mysql
I fixed this issue by running
sudo chown -R myUserName /usr/local/var/mysql
Here myUserName is my current login username.
Solution 50 - Mysql
I have to examine my error file in safe mode to find the root cause:
rm -f /usr/local/var/mysql/*.err
mysqld_safe start
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:
mysql.server start --upgrade=MINIMAL
, so the server will startmysqldump
won't work because it will try to run the full upgrade, but you can use Sequel Pro, phpMyAdmin, etc. to export.- Stop the server, rename the
mysql
folder tomysql.broken
, and do a clean install to get a freshmysql
folder. - Start MySQL, and manually import the
.sql
files you exported earlier.
Solution 51 - Mysql
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
.
.
.
Solution 52 - Mysql
try with sudo rm -rf /usr/local/var/mysql/HOSTNAME.err (HOSTNAME is my hostname)
Solution 53 - Mysql
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
Solution 54 - Mysql
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.