On Snow Leopard, starting MySQL gives the following error:
The server quit without updating PID file
[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
This question is related to
mysql
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.
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.
$ 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 be delete your database
This problem usually arrives when you did not have libaio.1 library installed. Install that package first and redo the mysql_install_db step.
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/*
For me the fix was simple:
top
showed that mysqld was already running
sudo killall mysqld
then allowed the process to start
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.
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
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
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.
Remove the pid file, then start up mysqld again.
In my case, the problem was, that mysql data directory was moved by accident to wrong directory (/var/log, and not to /var/lib). After moving data back to /var/lib/mysql and restarting server, all everything went back to normal again.
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.
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.
Could be related to old MySQL process. You need to kill it and restart. Sometimes it can be due to a conflict in MySQL config file. Try to move it and restart MySQL. Check the following url for more details.
http://linuxadministrator.pro/blog/?p=225
Thanks.
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
, then 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.
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
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...
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.
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
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
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/
I fixed this issue by running
sudo chown -R myUserName /usr/local/var/mysql
Here myUserName is my current login username
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
If no one answer helped you, just remove folder /usr/local/var/mysql
and then install mysql again brew reinstall mysql
.
I encountered this issue after swapping server IPs. Database was working fine before that. There was an entry in /etc/my.cnf that I needed to update:
bind-address = xxx.xxx.xxx.xx
It had the old IP address in there.
disable selinux in /etc/selinux/config
SELINUX=disabled
and restart the server
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!
This error can occur when trying to start msql after it was improperly shutdown.
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 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)
kill -15 4249
Kill -15 sends a siganl to the process to free up any resources it is locking and terminate the process after.
mysql.server start
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
(Enter your laptop password) If it gives below output... the PID issue is solved
sudo ./mysql.server start
@xxxx-M-R0SU support-files $ sudo ./mysql.server start Starting MySQL .. SUCCESS!
I had the same problem. moving my /etc/my.cnf file worked for me. I got the information here
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
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
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
Try this..
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)mysql.server start
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.
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
Delete *.err files that you find in the directory displayed in the error and create the file mysql is complaining about, restart mysql.
On Mavericks, this script helped me:
bash <(curl -Ls http://git.io/eUx7rg)
And then I reset my password according with https://stackoverflow.com/a/25883967/221781
After rebooting I had the same issue. Here is how I fixed it:
sudo chown -R _mysql /usr/local/var/mysql
The problem is a permissions one, it can't start because it can't write to mac.err because its 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 its all good. However, if you start it as root, it will create a mac.err (owned by root) file that jack can't write to, so when you try to restart it as jack it will fail.
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/
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.
I encountered this problem after reboot and removing all *err files.
It appeared for me that my.cnf.d directory was missing in /usr/local/etc.
It created it
mkdir /usr/local/etc/my.cnf.d
And just copy-pasted my.cnf et 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.
I had the same problem. The reason is quite simple. I installed 2 mysql server. One from Mac Port, the other from downloaded package. So I just follow the instruction here and uninstalled the one from package. How do you uninstall MySQL from Mac OS X? After that, mysql is working well.
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.
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
I tried remove all the *.err but still getting the same error. I got one of the error 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 delete all the ib* files and it works.
rm -f *.err ib*
Check if you have space left in your drive. I got this problem when no space left in my drive.
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 was no indication of why the startup failed in any of the normal logs. The wsrep recovery files had the answer, in my case I needed to start mysql with the following flag:
mysqld --tc-heuristic-recover=ROLLBACK
its a problem in 5.5 version
Here's an example for the [mysqld] section of your my.cnf:
skip-character-set-client-handshake
collation_server=utf8_unicode_ci
character_set_server=utf8
refers :http://dev.mysql.com/doc/refman/5.6/en/charset-server.html
In my case, I got this issue on vps, cPanel.
I was try most of the above answers, but not success.
ERROR! The server quit without updating PID file (/var/lib/mysql/111318.vps-11.com.pid).
[ERROR] Fatal error: Can't open and lock privilege tables: Table './mysql/db' is marked as crashed and should be repaired
[~]# myisamchk -r /var/lib/mysql/mysql/db.MYI
https://forums.cpanel.net/threads/mysql-is-not-running.407142/
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.
Source: Stackoverflow.com