MySql server PID not found - mysql

I have CentOS 6.4 with NGINX.
When I try to start/stop/restart mysql server (/etc/init.d/mysqld restart) I get this error:
MySQL server PID file could not be found! [FAILED]
Starting MySQL..The server quit without updating PID file ([FAILED]/mysql/mysqld.pid).
What can I do to solve this problem?
Thanks!

I got the same error on a CentOS 6.3 where I upgraded MySQL to 5.6.14 but I kept the old my.cnf file. After upgrade, MySQL did not start anymore, giving me the same error as you described.
The problem was that I had this setting in my.cnf:
table_cache=2048
According to this link table_cache renamed table_open_cache..
"Seem like in 5.5 the system variable table_cache was renamed
table_open_cache..
In 5.6 mysqld fails if it finds an unknown variable
this means that upgrades from versions earlier than 5.5 can have
problems if table_cache is specified in my.cnf."
After I changed the above line to
table_open_cache=2048
MySQL started perfectly.
So, in the case you have MySQL 5.5+ (and maybe an older my.cnf), I suggest you to do the following:
remove my.cnf from /etc folder and try to start MySQL
if MySQL starts, the the problem is in my.cnf. Comment/uncomment all the settings one by one in order to see which is causing the problem.
Hope this helps.

I upgraded my Mac OS to 10.9.3 and encountered the above problem on mysql.server restart
The following fixed my problem
sudo chmod -R o+rwx /usr/local/var/mysql/
sudo chown -R mysql /usr/local/var/mysql/
sudo mysql.server restart

First of all make sure that which folder/file is not exist in /var/run/mysqld/mysqld.pid
if dir not exists then create it as:
sudo mkdir -p /var/run/mysqld/
if mysqld.pid is not exists then create it as:
sudo touch /var/run/mysqld/mysqld.pid
change ownership as:
sudo chown mysql:mysql -R /var/run/mysqld
chmod 775 -R /var/run/mysqld
restart mysql service
sudo service mysql restart

I find that sometimes MySQL processes are still running. Certainly this was the case on my OS X Yosemite system so use the following command to find any processes that show up with MySQL in the name:
ps aux | grep mysql
Then kill them using the command
sudo kill -9 PID, replacing PID with the offending process ID.

Check if there is a lock.
/etc/init.d/mysql status
If the OS says that there is a lock, something like:
ERROR! MySQL is not running, but lock file (/var/lock/subsys/mysql) exists
remove that lock file and restart.

I found this worked....
# ps aux | grep mysql
root 3668 0.0 0.0 11432 1240 ? S 2014 0:00 /bin/sh /usr/bin/mysqld_safe --datadir=/db/data01 --pid-file=/var/lib/mysql/mysql.pid
mysql 5303 0.1 0.4 1964748 12368 ? S<l 2014 1663:35 /usr/sbin/mysqld --basedir=/usr --datadir=/db/data01 --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/db/logs01/mysql-error.err --open-files-limit=8192 --pid-file=/var/lib/mysql/mysql.pid --socket=/var/lib/mysql/mysql.sock --port=3306
root 12369 0.0 0.0 6376 680 pts/0 S+ 09:05 0:00 grep mysql
# kill -9 3668 5303
# rm /var/lock/subsys/mysql rm: remove regular empty file `/var/lock/subsys/mysql'? y
# service mysql start Starting MySQL (Percona Server).. SUCCESS!

Related

MySQL community server suddenly stopped working [duplicate]

My problem started off with me not being able to log in as root any more on my mysql install. I was attempting to run mysql without passwords turned on... but whenever I ran the command
# mysqld_safe --skip-grant-tables &
I would never get the prompt back. I was trying to follow these instructions to recover the password.
The screen just looks like this:
root#jj-SFF-PC:/usr/bin# mysqld_safe --skip-grant-tables
120816 11:40:53 mysqld_safe Logging to syslog.
120816 11:40:53 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
and I don't get a prompt to start typing the SQL commands to reset the password.
When I kill it by pressing CTRL + C, I get the following message:
error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!
If I retry the command and leave it long enough, I do get the following series of messages:
root#jj-SFF-PC:/run/mysqld# 120816 13:15:02 mysqld_safe Logging to syslog.
120816 13:15:02 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
120816 13:16:42 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
[1]+ Done mysqld_safe --skip-grant-tables
root#jj-SFF-PC:/run/mysqld#
But then if I try to log in as root by doing:
# mysql -u root
I get the following error message:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
I checked and /var/run/mysqld/mysqld.sock file doesn't not exist. The folder does, but not the file.
Also, I don't know if this helps or not, but I ran find / -name mysqld and it came up with:
/var/run/mysqld - folder
/usr/sbin/mysqld - file
/run/mysqld - folder
I don't know if this is normal or not. But I'm including this info just in case it helps.
I finally decided to uninstall and reinstall mysql.
apt-get remove mysql-server
apt-get remove mysql-client
apt-get remove mysql-common
apt-get remove phpmyadmin
After reinstalling all packages again in the same order as above, during the phpmyadmin install, I got the same error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
So I tried again to uninstall/reinstall. This time, after I uninstalled the packages, I also manually renamed all mysql files and directories to mysql.bad in their respective locations.
/var/lib/mysql
/var/lib/mysql/mysql
/var/log/mysql
/usr/lib/perl5/DBD/mysql
/usr/lib/perl5/auto/DBD/mysql
/usr/lib/mysql
/usr/bin/mysql
/usr/share/mysql
/usr/share/dbconfig-common/internal/mysql
/etc/init.d/mysql
/etc/apparmor.d/abstractions/mysql
/etc/mysql
Then I tried to reinstall mysql-server and mysql-client again. But I've noticed that it doesn't prompt me for a password. Isn't it supposed to ask for an admin password?
Try this command,
sudo service mysql start
To find all socket files on your system run:
sudo find / -type s
My Mysql server system had the socket open at /var/lib/mysql/mysql.sock
Once you find where the socket is being opened, add or edit the line to your /etc/my.cnf file with the path to the socket file:
socket=/var/lib/mysql/mysql.sock
Sometimes the system startup script that launched the command line executable specifies a flag --socket=path. This flag could override the my.cnf location, and that would result in a socket not being found where the my.cnf file indicates it should be. Then when you try to run the mysql command line client, it will read my.cnf to find the socket, but it will not find it since it deviates from where the server created one. So, Unless you care where the socket resides, just changing the my.cnf to match should work.
Then, stop the mysqld process. How you do this will vary by system.
If you're super user in the linux system, try one of the following if you don't know the specific method your Mysql setup uses:
service mysqld stop
/etc/init.d/mysqld stop
mysqladmin -u root -p shutdown
Some systems aren't setup to have an elegant way to stop mysql (or for some reason mysql doesn't respond) and you can force terminate mysql with either:
One step: pkill -9 mysqld
Two step (least preferred):
Find the process id of mysql with either pgrep mysql or ps aux | grep mysql | grep -v grep
Assuming the process id is 4969 terminate with kill -9 4969
After you do this you might want to look for a pid file in /var/run/mysqld/ and delete it
Make sure the permissions on your socket is such that whatever user mysqld is running as can read/write to it. An easy test is to open it up to full read/write and see if it still works:
chmod 777 /var/run/mysqld/mysqld.sock
If that fixes the issue, you can tailor the permissions and ownership of the socket as needed based on your security settings.
Also, the directory the socket resides in has to be reachable by the user running the mysqld process.
This error occurs due to multiple installations of mysql.
Run the command:
ps -A|grep mysql
Kill the process by using:
sudo pkill mysql
and then run command:
ps -A|grep mysqld
Also Kill this process by running:
sudo pkill mysqld
Now you are fully set just run the following commands:
service mysql restart
mysql -u root -p
Have very well working mysql again
The solution is way easier.
First, you have to locate(in Terminal with "sudo find / -type s") where your mysql.sock file is located. In my case it was in /opt/lampp/var/mysql/mysql.sock
Fire up Terminal and issue
sudo Nautilus
This starts your Files manager with super user privileges
From Nautilus navigate to where your mysql.sock file is located
Right click on the file and select Make Link
Rename the Link File to mysqld.sock then Right click on the file and Cut it
Go to /var/run and create a folder called mysqld and enter it
Now right click and Paste the Link File
Voila! You will now have a mysqld.sock file at /var/run/mysqld/mysqld.sock :)
Just Need to Start MySQL Service after installation:
For Ubuntu:
sudo service mysql start;
For CentOS or RHEL:
sudo service mysqld start;
There is a bug on Ubuntu with MySQL 5.6 and 5.7 where var/run/mysqld/ would disappear whenever MySQL service stopped or is rebooted. This prevents MySQL from running at all. Found this workaround, which isn't perfect, but at least it gets it running after stopping/reboot:
mkdir /var/run/mysqld/
chown mysqld /var/run/mysqld/
Make sure your inaccessible socket file path is same as '/var/run/mysqld/mysqld.sock', otherwise change the path as yours.
Stop the mysqld
$ sudo /etc/init.d/mysqld stop
If the process still runing;
$ sudo pkill -9 mysqld
Remove the mysql directory where socket going to create. For me it did not allowed to remove, so I had to forcefully remove.
$ sudo mkdir -p /var/run/mysqld
Set the ownership to the dirctory
$ sudo chown mysql:mysql /var/run/mysqld
Start mysql
$ sudo /etc/init.d/mysql start
Trying to connect mysql
$ sudo mysql -u dbuser -p
Okay just copy and paste these codes: This should be done in the terminal, inside a server, when your mysql database is not properly installed, and when you are getting this error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'.
Stop MySql
sudo /etc/init.d/mysqld stop
Restart it or start it
sudo /etc/init.d/mysqld restart or sudo /etc/init.d/mysqld start
Make a link like this and give it to the system
ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock
Run a secure installation which guides all the process you need to do to configure mysql
/usr/bin/mysql_secure_installation
I faced same error and found that it was due to upgradation of packages, So after restarting my system I resolved error.
I think due to sql libraries/ packages update that error occured, So try this if you are doing some upgrading :)
There is a lots of reason for this issue, but sometimes just restart the mysql server, it will fix the issue.
sudo service mysql restart
The answer of the user load step worked for me.
Sometimes is need edit the file in /etc/mysql/my.cnf add line to client
[client]
password = your_mysql_root_password
port = 3306
host = 127.0.0.1
socket = /var/lib/mysql/mysql.sock
Using XAMPP on ubuntu:
Create a folder called mysqld inside /var/run directory. You can accomplish that using the command sudo mkdir /var/run/mysqld.
Create a symbolic link to mysql.sock file that is created by the XAMPP server when it is started. You can use the command sudo ln -s /opt/lampp/var/mysql/mysql.sock /var/run/mysqld/mysqld.sock.
Note: The mysql.sock file is created when the server is started and removed when the server is stopped, so sometimes the link you created might appear to be broken but it should work as long as you have started the server using either sudo /opt/lampp/lampp start or any other means.
Start the server if it's not already running and try executing your program again.
Good luck! I hope you'll get away with it this time.
I think your MySQL server has not started. So start the server using one of the following commands.
#services mysql start
or
#/etc/init.d/mysql start
Why getting this error
I received new updates of mysql libraries so i updated my Kubuntu OS after that getting these errors.
Commands i tried and how i fixed it.
MySql-server is running correctly but when i tried to connect its giving
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'.
I checked /var/run/mysqld/mysqld.sock'. this directory.
My files did not existed.
I also tried these commands to connect but did not worked for me.
mysql -h 127.0.0.1 -P 3306 -u root -p
sudo service mysql start
After wasting round about 2 hours i found the solution
sudo apt-get clean
sudo apt-get update
sudo apt-get upgrade -f
After that everything fixed for me.
*Error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
solutions
finally uninstall and reinstall mysql. **
sudo apt-get remove mysql-server
sudo apt-get remove mysql-client
sudo apt-get remove mysql-common
sudo apt-get remove phpmyadmin
then install again by
sudo apt-get install mysql-server-5.6
After this operation, 164 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y press YES for complete installations
......
.......
At last you will get these lines....
Setting up libhtml-template-perl (2.95-1) ...
Setting up mysql-common-5.6 (5.6.16-1~exp1) ...
Processing triggers for libc-bin (2.19-0ubuntu6)
Processing triggers for ureadahead (0.100.0-16) ...
And then
root#ubuntu1404:~# mysql -u root -p (for every password first u
should use )
Enter password:
Note :Entered password should be same as the installation time
password of mysql(like .root,system,admin,rahul etc...)
Then type
USE rahul_db(database name);
Thanks.**
Temporary Solution
Maybe someone facing this problem. I am using Mysql Workbench on Ubuntu 14 and got this error.
mysqldump: Got error: 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) when trying to connect
Find your socket file by running sudo find / -type s, in my case it was /run/mysqld/mysqld.sock
So, I just created a link to this file in tmp directory.
sudo ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock
Please note that this is a temporary solution since the file created will be under /tmp. See other answers for a permanent solution.
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
in /etc/my.cnf add this lines:
[client]
socket=/var/lib/mysql/mysql.sock <= this path should be also same as is[mysqld]
And restart the service with:
service mysql restart
this worked for me
This was mentioned a couple of times already, but this worked immediately for me:
service mysql restart
you can find mysqld.sock in /var/run/mysqld if you have already installed mysql-server
by sudo apt-get install mysql-server
I just had this problem on Ubuntu 14.10
Turns that mysql-server was no longer installed (somehow it had been removed) but I couldn't just install it because there were some broken packages and dependency issues/conflicts.
In the end I had to reinstall mysql
sudo apt-get remove mysql-client
sudo apt-get install mysql-server
I had the exactly same issue. After struggling for an hour, I found a way of correcting it without reinstalling mysql-common, mysql-client, mysql-server.
First of all, go to "/var/run/mysqld". You will find that the mysql.sock does not exist. Simply remove the entire mysqld directory and recreate it and provide it necessary privileges.
# rm -rf /var/run/mysqld && mkdir /var/run/mysqld && chown mysql /var/run/mysqld/
Now, Kill the mysql process in it's entirety. It might be possible that it will show you "waiting for page cleaner" on running "/etc/init.d/mysql status" command even after shutting down the service.
To completely close the service, use
# pkill -9 mysqld
Once the process is killed, try starting it again using
# /etc/init.d/mysql start
And you will see that it works good! And also there will be no issue in stopping it too.
In My case two mysqld processes were running..
killed the optional processs by using
pkill -9 mysqld
If you have a lot of databases and tables on your system, and if you have innodb_file_per_table set in my.cnf, then your mysql server might have run out of opened objects / files (or rather the descriptors for these objects)
Set a new max number with
open-files-limit = 2048
and restart mysql.
This approach might help when the socket is not created at all, but really this might not not be the real problem, there is an underlying problem.
My solution;
Ubuntu 18.04 (WSL)
/etc/mysql/my.cnf
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
/etc/mysql/mysql.conf.d/mysqld.cnf
[mysqld]
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
I changed the port. It's worked for me. You can write another port. Example 3355
I am using XAMPP on Ubuntu. I found this error when connecting database through terminal. I solve it without any configuration because default socket file path in XAMPP is written in "/opt/lampp/etc/my.cnf" as following:
[client]
#password = your_password
port = 3306
socket = /opt/lampp/var/mysql/mysql.sock
now you can connect just by giving this socket path parameter with mysql command on terminal like:
mysql -u root --socket /opt/lampp/var/mysql/mysql.sock
and it's done without any configuration.
If you don't want to type socket path everytime, then go for changing default path in my.cnf by "/var/run/mysqld/mysqld.sock". Provide permissions and restart mysql server.
Edit:
Recently I've installed Ubuntu 20.04 and trying to install MySQL server but my system were crashing and not working at all. So I've just completely removed MySQL and installed MariaDB. Its working like a charm without any problems.
Changing the host to 127.0.0.1 worked for me.
Edit the file in /etc/mysql/my.cnf and add the below mentioned line to the section: client
[client]
port = 3306
host = 127.0.0.1
socket = /var/lib/mysql/mysql.sock
After you are done with it. Execute the following command.
sudo service mysql start
I had similar problem on a CentOS VPS. If MySQL won't start or keeps crashing right after it starts, try these steps:
1) Find my.cnf file (mine was located in /etc/my.cnf) and add the line:
innodb_force_recovery = X
replacing X with a number from 1 to 6, starting from 1 and then incrementing if MySQL won't start. Setting to 4, 5 or 6 can delete your data so be carefull and read http://dev.mysql.com/doc/refman/5.7/en/forcing-innodb-recovery.html before.
2) Restart MySQL service. Only SELECT will run and that's normal at this point.
3) Dump all your databases/schemas with mysqldump one by one, do not compress the dumps because you'd have to uncompress them later anyway.
4) Move (or delete!) only the bd's directories inside /var/lib/mysql, preserving the individual files in the root.
5) Stop MySQL and then uncomment the line added in 1). Start MySQL.
6) Recover all bd's dumped in 3).
Good luck!
I uninstalled mysql in Ubuntu 16.04 https://askubuntu.com/questions/172514/how-do-i-uninstall-mysql
I reinstalled mysql
https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-ubuntu-16-04
This seemed to work.
First create dir /var/run/mysqld
with command:
mkdir -p /var/run/mysqld
then add rigths to the dir
chown mysql:mysql /var/run/mysqld
after this try
mysql -u root
You must install mysql-server
apt install mysql-server

MySQL deactivated in Lampp, Xampp on Linux 12.04

I have freshly installed xampp-linux-1.8.1 on my Ubuntu 12.04 (Mint 13 maya) Operating system.
When run lampp, I get :
/opt/lampp/lampp start
Starting XAMPP for Linux 1.8.1...
XAMPP: XAMPP-Apache is already running.
XAMPP: Another MySQL daemon is already running.
XAMPP: XAMPP-ProFTPD is already running.
XAMPP for Linux started.
In the : localhost/xampp/
MySQL DataBase is Deactivated !!!
ps -aux | grep 'mysql'
Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html mysql 3159 0.0 0.9 316264 31880 ? Ssl 16:48 0:00 /usr/sbin/mysqld
root 4745 0.0 0.0 4648 840 pts/5 S+ 17:02 0:00 grep --color=auto mysql
When I tried to stop /usr/sbin/mysqld but it can't be stopped with this command !!!
/usr/sbin/mysqld stop
Please I need Help, Thanks.
i've resolved the issue in this way:
sudo chmod -R 777 /opt/lampp
sudo chown -hR nobody /opt/lampp
sudo chmod -R 755 /opt/lampp
then stop other mysqld running with:
sudo service mysql stop
Also had this issue, after troubleshooting for almost 2 hours I found that it was because of other Apache and MySQL packages also running on my system. Removed all Apache and MySQL packages and reinstalled XAMPP again. Success.

After MySQL install via Brew, I get the error - The server quit without updating PID file

Ok, I've searched all over and have spent quite a bit of my time installing, uninstalling, trying various option but without success.
I'm on Mac OS X Lion (10.7.3) and am trying to setup a Python, MySQL.
I successfully installed Python and MySQL via HomeBrew.
Python works great.
After MySQL Installation, I followed the first 2 steps - unset and the mysql_install_db commands.
Now, when I try to start mysql "mysql.server start", I get the following error
ERROR! The server quit without updating PID file (/usr/local/var/mysql/Brajeshwar.local.pid).
Brajeshwar is my username on my machine.
I found that it was a permissions issue with the mysql folder.
chmod -R 777 /usr/local/var/mysql/
solved it for me.
EDIT 2012/09/18:
As pointed out by Kane, make sure the mysql database is properly set up before doing anything else. See “PID error on mysql.server start?” for more info.
Original answer kept for history's sake:
It most likely is a permissions issue. Check /usr/local/var/mysql/*.err. Mine said:
120314 16:30:14 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 ./ibdata1
InnoDB: File operation call: 'open'.
InnoDB: Cannot continue operation.
120314 16:30:14 mysqld_safe mysqld from pid file /usr/local/var/mysql/janmoesen.local.pid ended
I also had to do this:
sudo chown _mysql /usr/local/var/mysql/*
I ended up with completely reinstalling of mysql, and it finally worked out.
WARNING This will remove all of your databases, so make sure to save dumps first.
brew remove mysql
brew cleanup
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
sudo rm -rf /usr/local/var/mysql
brew install mysql
mysqld --initialize --explicit_defaults_for_timestamp
mysql.server start # no sudo!
I had this issue on mac 10.10.5 Yosemite
What I did to solve this
cd /usr/local/var/mysql
sudo rm *.err && sudo rm *.pid
sudo reboot
sudo mysql.server start
I had the same issue on OS X El Capitan, here's the terminal command sequence that fixed it for me.
Delete error files (you'll have to change the path depending on your setup)
sudo rm /usr/local/mysql/data/*.err
Find the info for the mysql process that's still running and kill it:
ps -A | grep -m1 mysql | awk '{print $1}' | sudo xargs kill -9
Now restart MySQL:
/usr/local/mysql/support-files/mysql.server start
November, 2014: If you're getting this error on MySQL 5.6.x on Mac OS X Mavericks or Yosemite and want to use MySQL with PHP locally (/tmp/mysql.sock is where PHP PDO expects to find the sock file), here is what fixed it for me:
1) Uncomment the default homebrew config file lines and edit as below
$ sudo vi /usr/local/Cellar/mysql/5.6.21/my.cnf
...
basedir = /usr/local/Cellar/mysql/5.6.21
datadir = /usr/local/var/mysql
port = 3306
server_id = <UNIQUE_NUMBER_HERE_OR_LEAVE_COMMENTED_OUT>
socket = /tmp/mysql.sock
pid-file = /usr/local/var/mysql/[BOXNAME].local.pid
....
BOXNAME is what you have in your System Prefs -> Network as the unique id for your computer on the network.
2) Set permissions on all the files in the mysql datadir. These were all owned by [my_username]. MySQL is very picky about this and refuses to create the pid file unless it (the user _mysql) owns the directory.
$ sudo chown -R _mysql:mysql /usr/local/var/mysql
3) Start MySQL using the bash helper/wrapper script:
$ sudo mysql.server start
Starting MySQL
. SUCCESS!
Hope that helps. If the above doesn't work for you, try to run the mysqld_safe binary manually in the Cellar/mysql/VERSION_/bin/ directory and check what the settings are (if it runs)
sudo /usr/local/Cellar/mysql/5.6.12/bin/mysqld_safe &
If that runs, you can
ps aux | grep mysql
and see something like
[username] 6881 0.0 2.7 3081392 454836 ?? S 8:52AM 0:00.54 /usr/local/Cellar/mysql/5.6.21/bin/mysqld --basedir=/usr/local/Cellar/mysql/5.6.21 --datadir=/usr/local/var/mysql --plugin-dir=/usr/local/Cellar/mysql/5.6.21/lib/plugin --verbose --log-error=/usr/local/var/mysql/BOXNAME.local.err --pid-file=/usr/local/var/mysql/BOXNAME.local.pid
I'm not sure why that worked for me but it shows you where I got the my.cnf config file options from. You can also use the command line options to try to troubleshoot when starting mysqld manually.
If you do run manage to run MySQL server using mysqld_safe, you may have to do this to shut it down before trying the mysql.server bash helper. Resist the urge to kill -9 [PID] because you can corrupt your data.
mysqladmin -uroot shutdown
Good luck!
This worked for me:
sudo chmod -R 777 /usr/local/var/mysql/
sudo /usr/local/mysql/support-files/mysql.server start
This worked for me on 10.12.2 :
$ rm /usr/local/var/mysql/*.err
then
$ brew services restart mysql
If I remember correctly it is a permissions issue. Try to 'touch' and 'chmod' the pid file or the folder the file is held in.
My issue was that I started server as sudo once and then tried to restart as a local user.
Here mysql was not able to write to '.err' file owned by root.
I had to remove that file and restart the server:
sudo rm /usr/local/var/mysql/*.err
mysql.server start
Try this (OSX)
Step 1:
ps -aux | grep mysql
Then kill the 4 digits PID number
Step 2: kill 1965
Step 3: mysql.server start
Or having hard time to locate those PID numbers, try this below
Step 1 again: ps -aux | grep mysql
Step 2 again: killall
Step 3 again: mysql.server start
I’ve got a similar problem with MySQL on a Mac (Mac Os X Could not startup MySQL Server. Reason: 255 and also “ERROR! The server quit without updating PID file”). After a long trial and error process, finally in order to restore the file permissions, I’ve just do that:
launch the Disk Utilities.app
choose my drive on the left panel
click on the “Repair disk permissions” button
This did the trick for me. Hoping this can help someone else.
Find usr/local/var/mysql/your_computer_name.local.err file and understand the more information about error
Location : /usr/local/var/mysql/your_computer_name.local.err
It's probably problem with permissions
Find if mysql is running and kill it
ps -ef | grep mysql
kill -9 PID
where PID is second column value
2. check ownership of mysql
ls -laF /usr/local/var/mysql/
if it is owned by root, change it mysql or your user name

sudo chown -R mysql /usr/local/var/mysql/
For me it worked with:
unset TMPDIR
mysql_install_db --user=`whoami` --basedir="$(brew --prefix mariadb)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
What worked for me was:
Go to your mysql installation directory
sudo chmod -R 777 data
Then go back one directory
cd support-files/
sudo ./mysql.server start
After that the server started running.
But the problem with this method is that I have to repeat this every time I want to start the mysql now. Don't know why it started behaving like this suddenly.
I had this problem on Linux, but the cause is relevant to any mysql installation. In my case, the server was crashing before startup was complete and the pid file updated. The error messages were seen when starting up mysqld directly instead of via "service mysql start".
In my case, the cause was the partition where the log files were located being full. Removing log files permitted mysql to start again. To test for this issue, go to the location of your mysql activity logs, and do df ..
If you have upgraded your mysql installation to 8.x, check if your previous version is supported for upgradation.
If not, mysql will not work! Uninstall your mysql along with all configuration files in /usr/local/var/mysql (remove the whole folder). Reinstall mysql.
NOTE: reinstalling might lead to loss of data.
Please check the log , you will get more detailed information .
Use the below command to tail the error log
tail -100 /usr/local/var/mysql/<user_name>.local.err
For me , one of the directory is missing , once created the server has started .
The key takeaway is to check the .err file, by default on Mac OSX it's in /usr/local/var/mysql.
That log filed revealed to me that I had to delete the following files:
ibdata1
ib_logfile0
ib_logfile1
Running MySQL with mysql.start worked successfully after that. Note that deleting those files will likely causes data loss.
sudo chmod -R 777 /usr/local/var/mysql/
works for me.
I had the same issue:
But the situation was, every time i try to enter:
/usr/local/mysql/support-files/mysql.server start
a file named localhost.pid is created instead of iMax0.local.pid which was stated in the error:
ERROR! The server quit without updating PID file (/usr/local/mysql/data/iMax0.local.pid).
Solution that works for me was copying localhost.pid and renaming it to iMax0.local.pid.
My solution on OSX El Capitan was:
sudo chmod ugo+w /tmp
It was broken suddenly.
The error was:
ERROR! The server quit without updating PID file
and the log showed:
Can't start server : Bind on unix socket: Permission denied
It might also be helpful to note, that under OSX there is no my.cnf file by default and not needed by default, which I did not know. Good luck!
$ sudo mysql.server restart
It works for me.
I had the similar issue. But the following commands saved me.
cd /usr/local/Cellar
sudo chown _mysql mysql
This is file permission problem.
Check disk permissions and repair.
Osx => Cmd+Space => Disk Utilty => Verify Disk Permissions.
Verify completed after Repair Disk Permissions.
mysql.server start command is worked succesfuly.
None of the answers worked for me. However, I simply did sudo mysql.server start and it worked nicely.
Also, for me, it did NOT show permissions issue in *.err file.
all solutions above doesn't work for me.
but they give me some clues to fix this error.
mysql.server start ----error The server quit without updating PID file
I installed mysql#5.7 on my macbook mojave with homebrew
brew install mysql#5.7
mysql error log located in /usr/local/var/mysql/IU.lan.err,there is one line in it:
Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
after trying many posts in goole search engine,I turned to baidu
https://blog.csdn.net/xhool/article/details/52398042
inspired by this post,I found the solution:
rm /usr/local/var/mysql/*
mysqld --initialize
a random password for root user will be shown in bash.
but the command mysql -uroot -p[theRandomPassword] cant work.so I have to reset password.
create a init file with contents like this
SET PASSWORD FOR 'root'#'localhost' = PASSWORD('MyNewPass');
place it in any directory easy to find,such as Desktop
mysqld --init-file=[YourInitFile] &
many logs printed on your screen.
mysql -uroot -pMyNewPass
enjoy your high-version mysql!
Happened to me because I was actually switching from MariaDB to Mysql.
Switching back to MariaDB solved this.
I'm guessing the existing database wasn't compatible.
Solved this using sudo chown -R _mysql:_mysql /usr/local/var/mysql
Thanks to Matteo Alessani
This error may be actually being show because mysql is already started. Try to see the current status by:
mysql.server status

How to start MySQL server from command line on Mac OS Lion?

I installed mySQL on my Mac. Beside starting the SQL server with mySQL.prefPane tool installed in System Preferences, I want to know the instructions to start from command-line.
I do as follows:
After
su root
I start the mySQL server by command-line, but it produces an error as below:
sh-3.2# /usr/local/mysql/bin/mysqld
111028 16:57:43 [Warning] Setting lower_case_table_names=2 because
file system for /usr/local/mysql-5.5.17-osx10.6-x86_64/data/ is case
insensitive
111028 16:57:43 [ERROR] Fatal error: Please read "Security" section of
the manual to find out how to run mysqld as root!
111028 16:57:43 [ERROR] Aborting
111028 16:57:43 [Note] /usr/local/mysql/bin/mysqld: Shutdown complete
Simply:
mysql.server start
mysql.server stop
mysql.server restart
Try /usr/local/mysql/bin/mysqld_safe
Example:
shell> sudo /usr/local/mysql/bin/mysqld_safe
(Enter your password, if necessary)
(Press Control-Z)
shell> bg
(Press Control-D or enter "exit" to exit the shell)
You can also add these to your bash startup scripts:
export MYSQL_HOME=/usr/local/mysql
alias start_mysql='sudo $MYSQL_HOME/bin/mysqld_safe &'
alias stop_mysql='sudo $MYSQL_HOME/bin/mysqladmin shutdown'
I like the aliases too ... however, I've had issues with MySQLCOM for start ... it fails silently ... My workaround is akin to the others ... ~/.bash_aliases
alias mysqlstart='sudo /usr/local/mysql/support-files/mysql.server start'
alias mysqlstop='sudo /usr/local/mysql/support-files/mysql.server stop'
As this helpful article states:
On OS X to start/stop MySQL from the command line:
sudo /usr/local/mysql/support-files/mysql.server start
sudo /usr/local/mysql/support-files/mysql.server stop
On Linux start/stop from the command line:
/etc/init.d/mysqld start
/etc/init.d/mysqld stop
/etc/init.d/mysqld restart
Some Linux flavours offer the service command too
# service mysqld start
# service mysqld stop
# service mysqld restart
or
# service mysql start
# service mysql stop
# service mysql restart
If you installed it with homebrew, the binary will be somewhere like
/usr/local/Cellar/mysql/5.6.10/bin/mysqld
which means you can start it with
/usr/local/Cellar/mysql/5.6.10/support-files/mysql.server start
and stop it with
/usr/local/Cellar/mysql/5.6.10/support-files/mysql.server stop
Edit: As Jacob Raccuia mentioned, make sure you put the appropriate version of MySQL in the path.
Maybe your mysql-server didn't start.
You can try
/usr/local/bin/mysql.server start
sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop
make alias in .bash_profile
alias start_mysql="/Library/StartupItems/MySQLCOM/MySQLCOM start"
alias stop_mysql="/Library/StartupItems/MySQLCOM/MySQLCOM stop"
and if you are trying to run as root use following safe mode
sudo ./bin/mysqld_safe
if you are still having issues starting, a recommended read:
mysql5.58 unstart server in mac os 10.6.5
For me this solution worked on mac Sierra OS:
sudo /usr/local/bin/mysql.server start
Starting MySQL
SUCCESS!
My MySQL is installed via homebrew on OS X ElCaptain. What fixed it was running
brew doctor
which suggested that I run
sudo chown -R $(whoami):admin /usr/local
Then:
brew update
mysql.server start
mysql is now running
If it's installed with homebrew try just typing down mysql.server in terminal and that should be it.
AFAIK it executable will be under /usr/local/bin/mysql.server.
If not you can always run following "locate mysql.server" which will tell you where to find such file.
If you have MySQL installed through Homebrew these commands will help you:
# For starting
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
# For stoping
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
MySql server startup error 'The server quit without updating PID file '
if you have installed mysql from homebrew
close mysql server from preferences of mac
ps ax | grep mysql
#kill all the mysql process running
sudo kill -9 pid
which mysql
/usr/local/bin/mysql
Admins-MacBook-Pro:bin username$ sudo mysql.server start
Starting MySQL
. SUCCESS!
Admins-MacBook-Pro:bin username$ which mysql
/usr/local/bin/mysql
Admins-MacBook-Pro:bin username$ ps ax | grep mysql
54916 s005 S 0:00.02 /bin/sh
/usr/local/Cellar/mysql#5.7/5.7.27_1/bin/mysqld_safe --datadir=/usr/local/var/mysql --pid-file=/usr/local/var/mysql/Admins-MacBook-Pro.local.pid
55012 s005 S 0:00.40 /usr/local/Cellar/mysql#5.7/5.7.27_1/bin/mysqld --basedir=/usr/local/Cellar/mysql#5.7/5.7.27_1 --datadir=/usr/local/var/mysql --plugin-dir=/usr/local/Cellar/mysql#5.7/5.7.27_1/lib/plugin --user=mysql --log-error=Admins-MacBook-Pro.local.err --pid-file=/usr/local/var/mysql/Admins-MacBook-Pro.local.pid
55081 s005 S+ 0:00.00 grep mysql
On mac Big Sur and MySQL 5.7, I needed to stop/start with:
sudo launchctl load -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
and
sudo launchctl unload -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
This answer came from https://coolestguidesontheplanet.com/start-stop-mysql-from-the-command-line-terminal-osx-linux/
In my case, I had downloaded the mysql server and installed it but I didn't click on the run server that showed up on the last installer page.
In order to start my server manually in the terminal (without adding aliases), I used this in the terminal and it works.
Start Server:
sudo launchctl load -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
Stop Server:
sudo launchctl unload -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
More info at the link below:
https://www.databasestar.com/start-mysql-server/
111028 16:57:43 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!
Have you set a root password for your mysql installation? This is different to your sudo root password. Try /usr/local/mysql/bin/mysql_secure_installation

PID error on mysql.server start?

I've just tried installing MySQL using homebrew (on Mac OS X 10.6), but I've run across an issue at the first hurdle. When trying to manually start the server (mysql.server start), I get the following error:
. ERROR! Manager of pid-file quit without updating file.
Unfortunately I'm not sure of which error logs or configuration files to check, as I've never installed MySQL in this way before.
I ran into this same problem when installing via homebrew. Make sure you run these commands (which are listed during install but easy to miss):
unset TMPDIR
mysql_install_db
You probably need to ensure that you're running mysql as the root user -- otherwise it won't have permission to write the PID file (thus the error you're receiving).
Try this:
sudo mysql.server start
You'll be prompted for your password. (this assumes that your user account has permissions to "sudo" -- which it should, unless it's setup as a restricted user account in OS X).
This may not be the only issue -- but it should get you to the next step anyway.
I ran into the same issue while trying to install MySQL 5.5.15 in Lion using homebrew and resolved the issue with:
mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
and creating a the file ~/my.cnf
with the content:
[mysqld]
basedir=/usr/local/Cellar/mysql/5.5.15
datadir=/usr/local/var/mysql
basedir - should be your current MySQL instalation dir
datadir - should be the location of MySQL data
You can figure out that too location by watching the make command during the "brew install mysql" searching for something like this:
-DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/mysql/5.5.15 -DMYSQL_DATADIR=/usr/local/var/mysql -DINSTALL_MANDIR=/usr/local/Cellar/mysql
Where DCMAKE_INSTALL_PREFIX = basedir and DMYSQL_DATADIR = datadir
Nothing else really helped, but the following worked:
$ ps aux | grep mysql
tagir 27260 0.0 1.0 3562356 175120 ?? S 2:52PM 0:00.42 mysqld --skip-grant-tables
tagir 42704 0.0 0.0 2434840 784 s000 S+ 3:04PM 0:00.00 grep mysql
$ kill 27260
# Careful! This might erase your existing data
$ rm -rf /usr/local/var/mysql
$ mysqld --initialize
$ mysql.server start
These following two commands should solve your issue.
> unset TMPDIR
> mysql_install_db --verbose --user=\`whoami\` --basedir="$(brew
--prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
I am adding this here because I encountered this problem several times after installing other software. MySQL was working fine for days, then suddenly I get this error.
It seems to happen when I install something (eg. elasticsearch or Puma web server). The MySql permissions get reverted again (back to me, and not _mysql). No idea why.
MacOS Sierra
Homebrew 1.0.5-43-g41b2df8 (2016-10-02)
MySQL 5.7.15
So I have found that one cause of this is the permissions on the location where MySQL stores your databases, which by default is here:
/usr/local/var/mysql
If you look in that folder you will see a file
<your computer name>.err
If you look inside that file (more it or cat it) you will probably see this error:
[ERROR] InnoDB: The innodb_system data file 'ibdata1' must be writable
If so then you know it is a permissions issue.
If you don't care, you can probably just run MySQL by just running mysqld (and leave that terminal open).
If you do care:
ls -al /usr/local/var/mysql
you will notice that the permissions are probably all set to you (your user account). This means mysql cannot mount your databases when you run it using the homebrew shortcut sudo mysql.server start [even though you are using sudo to run in 'admin' mode].
So, change the permissions:
$ sudo chown -R _mysql /usr/local/var/mysql
$ sudo chmod -R o+rwx /usr/local/var/mysql
Then it will work.
It appears that for whatever reason I can't comment below Immendes above, but on 10.8.2 with mySQL 5.6.10, in addition to verifying the db_install and adding the my.cnf, I also had to chown -R myusername /tmp/mysql.sock.
It appears that allowing mySQL to run under the user (as apposed to root or www as I woudl do on linux) is not the best idea in this regard (though Homebrew could update the formula -- beyond my scope and time).
brew postinstall mysql
delete document /opt/homebrew/var/mysql
brew postinstall mysql