Several problems with mysql since last Sierra Update.
Reinstalled several times with brew or mysql dmg and followd many many "solutions" on SO.
Finally it worked but after a Mac Crash, I face the same problem.
MySql won't start from preference panel
Mysql won't start from terminal: Can't connect through /tmp/mysql.sock...of course, mysqld is not running
trying to start mysqld:
sudo /usr/local/mysql/support-files/mysql.server start
ERROR! The server quit without updating PID file (/usr/local/mysql/data/My-iMac.local.pid)
sudo /usr/local/mysql/bin/mysqld several errors and shutdown
a bit stuck
Just tried this
sudo /usr/local/mysql/bin/mysqld_safe
mysqld_safe Logging to '/usr/local/mysql/data/My-iMac.local.err'.
Starting mysqld daemon with databases from /usr/local/mysql/data
mysqld_safe mysqld from pid file /usr/local/mysql/data/My-iMac.local.pid ended
And now looking at error log, the explanation is clear:
tail /usr/local/mysql/data/My-iMac.local.err
InnoDB: corrupt if we cannot apply the log records in the InnoDB log to it.
So I added in my.cnf
[mysqld]
innodb_force_recovery = 1
and now it starts!
It was probably due to previous Mac Crash
In my case the owner of the data folder was changed after an OS update.
After fixing this with …
sudo chown -R mysql /usr/local/mysql/data
… everything worked like a charm again.
Oh, I feel your pain. I've had this happen many times. Stopping the processes didn't always work. To solve this I simply went into System Preferences and MySQL... stop the process from there and try to restart.
I tried to kill mysql process since it was giving me an error as:
The server quit without updating PID file. But whenever I killed the process by PID, it created a new PID and the process persisted. Any explanation on this issue will be appreciated! The code I tried was as follows:
ps aux | grep mysql
sudo kill -9 [PID]
MySql was installed on Mac from .dmg file. And it was initially working fine, the error happens after it has already worked for a while.
have you tried to stop it using the daemon manager with service (linux):
service mysql stop
and for Mac:
sudo /usr/local/mysql/support-files/mysql.server stop
Hope it helps.
I know this is a widelly answered question but I cannot find one solution that apply to my case.
On OSX El Capitan, I recently switched from a MAMP install to a "manual" install of MySQL, using the dmg package (version 5.7.11).
Now I want to modify the datadir to a custom location ; it used to work but I stopped the server and it doesn't want to start anymore. I tried launching it using:
sudo mysql.server start
sudo mysqld_safe
...but I always get this error: The server quit without updating PID file (/Users/xxx/Documents/dev/MySQL/data/xxx.pid). But it starts whan I set back the datadir to its original location! (which is /usr/local/mysql/data)
First time I had this issue it was clearly documented in the .err file (error 13 if I remember well, which is an access problem) and it was fixed by the magic combination of sudo chown -R _mysql:wheel data/ and sudo chmod -R 777 data/. Now both original and custom datadir have the same owners (user and group) and same read/write permissions. But server will start for one and not for the other? And the .err file only logs:
mysqld_safe Starting mysqld daemon with databases from /Users/xxx/Documents/dev/MySQL/data
mysqld_safe mysqld from pid file /Users/xxx/Documents/dev/MySQL/data/xxx.pid ended
Which doesn't helps me much.
Any ideas please?
I have a strange error when starting mysqld service:
Another MySQL daemon already running with the same unix socket.
I've tried to list running services and stopping them but the same error happens when starting mysqld service.
I can try to remove the mysqld and reinstall it but will this remove the database too?
To prevent the problem from occurring, you must perform a graceful shutdown of the server from the command line rather than powering off the server.
# shutdown -h now
This will stop the running services before powering down the machine.
Based on Centos, an additional method for getting it back up again when you run into this problem is to move mysql.sock:
# mv /var/lib/mysql/mysql.sock /var/lib/mysql/mysql.sock.bak
# service mysqld start
Restarting the service creates a new entry called mqsql.sock
TL;DR:
Run this as root and you'll be all set:
rm $(grep socket /etc/my.cnf | cut -d= -f2) && service mysqld start
Longer version:
You can find the location of MySQL's socket file by manually poking around in /etc/my.conf, or just by using
grep socket /etc/my.cnf | cut -d= -f2
It is likely to be /var/lib/mysql/mysql.sock. Then (as root, of course, or with sudo prepended) remove that file:
rm /var/lib/mysql/mysql.sock
Then start the MySQL daemon:
service mysqld start
Removing mysqld will not address the problem at all. The problem is that CentOS & RedHat do not clean up the sock file after a crash, so you have to do it yourself. Avoiding powering off your system is (of course) also advised, but sometimes you can't avoid it, so this procedure will solve the problem.
I have found a solution for anyone in this problem
change the socket dir to a new location in my.cnf file
socket=/var/lib/mysql/mysql2.sock
and service mysqld start
or the fast way as GeckoSEO answered
# mv /var/lib/mysql/mysql.sock /var/lib/mysql/mysql.sock.bak
# service mysqld start
My solution to this was a left over mysql.sock in the /var/lib/mysql/ directory from a hard shutdown.
Mysql thought it was already running when it was not running.
Just open a bug report with your OS vendor asking them to put the socket in /var/run so it automagically gets removed at reboot. It's a bug to keep this socket after an unclean reboot, /var/run is the spot for these kinds of files.
in order to clean automatically .sock file, place these lines in file /etc/init.d/mysqld immediately after "start)" block of code
test -e /var/lib/mysql/mysql.sock
SOCKEXIST=$?
ps cax | grep mysqld_safe
NOPIDMYSQL=$?
echo NOPIDMYSQL $NOPIDMYSQL
echo SOCKEXIST $SOCKEXIST
if [ $NOPIDMYSQL -eq 1 ] && [ $SOCKEXIST -eq 0 ] ; then
echo "NOT CLEAN"
rm -f /var/lib/mysql/mysql.sock
echo "FILE SOCK REMOVED"
else
echo "CLEAN"
fi
it worked for me. I had to do this because I have not an UPS and often we have power supply failures.
regards.
It may sometime arises when MySQL service does not shut down properly during the OS reboot.
The /var/lib/mysql/mysql.sock has been left. This prevents 'mysqld' from starting up.
These steps may help:
1: service mysqld start
killall -9 mysqld_safe mysqld
service mysqld start
2: rm /var/lib/mysql/mysql.sock
service mysqld start
To start the MySQL service, you can remove '/var/lib/mysql/mysql.sock' and start the MySQL service again:
Remove the socket file:
[root#server ~]# rm /var/lib/mysql/mysql.sock
rm: remove socket `/var/lib/mysql/mysql.sock'? yes
Start the MySQL service:
[root#server~]# service mysqld start
Starting mysqld: [ OK ]
It will help you to resolve your problem.
It's just happen because of abnormal termination of mysql service. delete or take backup of /var/lib/mysql/mysql.sock file and restart mysql.
Please let me know if in case any issue..
I just went through this issue and none of the suggestions solved my problem. While I was unable to start MySQL on boot and found the same message in the logs ("Another MySQL daemon already running with the same unix socket"), I was able to start the service once I arrived at the console.
In my configuration file, I found the following line: bind-address=xx.x.x.x. I randomly decided to comment it out, and the error on boot disappeared. Because the bind address provides security, in a way, I decided to explore it further. I was using the machine's IP address, rather than the IPv4 loopback address - 127.0.0.1.
In short, by using 127.0.0.1 as the bind-address, I was able to fix this error. I hope this helps those who have this problem, but are unable to resolve it using the answers detailed above.
I am getting this error
mysql is not running but lock exist
when I am checking the status of MySQL server. I have removed the lock files using following command:
rm /var/lock/subsys/mysql
but still I am getting same error.
Can anyone provide any input on this.
try using the unix lsof command to see which program has the lock
lsof | grep mysql
EDIT:in fact, run lsof on the lock itself
lsof /var/lock/subsys/mysql
I had the same error. It started after an unexpected server reboot. I saw there is a default /etc/my.cnf file which is not in use for my installation. The issue resolved when it renamed my.cnf as my.cnf_old
For this similar error:
service mysql status ERROR! MySQL is not running, but lock file
(/var/lock/subsys/mysql) exists
Follow these steps:
rm /var/lock/subsys/mysql rm:
remove regular empty file
/var/lock/subsys/mysql? y
Press y
/etc/init.d/mysql start.
If the error occurs again after starting MYSQL
then execute ps -ef | grep mysql
Kill all processes of MySQL and repeat steps 1 & 2.
I know this post is a quite old, but I like to make notes on the ones that work for issue that I've experienced recently. I was getting the following message, which lead me here:
service mysql status ERROR! MySQL is not running, but lock file
(/var/lock/subsys/mysql) exists
These are the steps that fixed my issues:
mv /etc/my.cnf /etc/my.cnf_old
rm /var/lock/subsys/mysql
/etc/init.d/mysql start
Starting MySQL.210921 16:46:28 mysqld_safe Logging to '/var/lib/mysql/server001.err'.
210921 16:46:28 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql. SUCCESS!