failing to start mysql server client after upgrading with brew (os Mojave) - mysql

I just did Brew update mysql and then closed my mysql.
tried to start again and bam:
~ » mysql.server start
Starting MySQL
. ERROR! The server quit without updating PID file (/usr/local/var/mysql/Johns-MBP-2.pid).
never had this issue before, was going over all the stackoverflow answers about this situation and nothing worked :\
in the .err file I see:
InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
Unable to lock ./ibdata1 error: 35

You possibly have another instance(s) of mysql running.
You can check with the command:
pgrep mysql
If it returns some id, you can kill it/them with the command below before attempting to start mysql again:
pkill mysql
Update:
If mysql keep spawning with a new process id, it probably means there's a mysql agent (daemon) that you need to unload first:
Check for it:
launchctl list | grep mysql
And acutally unload it:
launchctl unload "Library/LaunchAgents/$(launchctl list | grep mysql | grep -v grep | awk '{print $3}').plist"

Related

Can mysqld process be killed?

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.

Can't get MySQL to work on OS X 10.9

I know there are tons of posts about this problem but, I have tried all the solutions I have seen, and none are working. I have been working on this for two days now...it seems like I should be able to get a simple install working. Here are the facts:
I downloaded mysql-5.6.15-osx10.7-x86_64.dmg from the MySQL site. I opened and ran the mysql-5.6.15-osx10.7-x86_64.pkg. Then I went to the command line and tried a long list of commands to start MySQL and NOTHING works.
Here is a list of some of my attempts and their results:
~ $ mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (2)
~ $ mysqld
2014-01-13 19:52:20 0 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.
2014-01-13 19:52:20 0 [Warning] Using unique option prefix thread_cache instead of thread_cache_size is deprecated and will be removed in a future release. Please use the full name instead.
2014-01-13 19:52:20 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2014-01-13 19:52:20 953 [Warning] Can't create test file /usr/local/mysql-5.6.15-osx10.7-x86_64/data/rogerknwlessmbp.lower-test
2014-01-13 19:52:20 953 [Warning] Can't create test file /usr/local/mysql-5.6.15-osx10.7-x86_64/data/rogerknwlessmbp.lower-test
mysqld: File './mysql-bin.index' not found (Errcode: 13 - Permission denied)
2014-01-13 19:52:20 953 [ERROR] Aborting
~ $ sudo mysqld
After several warnings about deprecated settings, I got:
2014-01-13 20:27:55 1311 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!
2014-01-13 20:27:55 1311 [ERROR] Aborting
2014-01-13 20:27:55 1311 [Note] Binlog end
~ $ sudo /usr/local/mysql/bin/mysqld_safe
140113 20:30:08 mysqld_safe Logging to '/usr/local/mysql/data/rogerknwlessmbp.err'.
140113 20:30:09 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
140113 20:30:11 mysqld_safe mysqld from pid file /usr/local/mysql/data/rogerknwlessmbp.pid ended
~ $ sudo /usr/local/mysql/support-files/mysql.server start
Starting MySQL
... ERROR! The server quit without updating PID file (/usr/local/mysql/data/rogerknwlessmbp.pid).
I read one post that said this was a permissions issue, and that the solution was to rebuild permissions using the Disk Utility app in Mac OS X. I have done that with no effect.
Over the past few days, I have tried so many things, I can't keep track but, they all get about the same results. I have tried installing earlier versions, different versions (x86), and on and on. If anyone has a recommendation as to what else I might try I would really appreciate it. I would love to get MySQL working on this machine. It was on my machine and working at one point but, I uninstalled it because of some problems I was having long ago. Now, I can't get it to work.
Thanks for any advice you can give.
I believe socket should link to /var/lib/mysql/mysql.sock
You can edit a file that is usually in /etc/mysql/ folder and fine a line starting with socket=
Try putting /var/lib/mysql/mysql.sock as a value for this.
I believe you can see a location for mysql.sock by running this command
$ mysqladmin variables | grep socket
If it's /tmp/mysql.sock
you can try sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock too
Finally! I got it to install and to start.
Essentially, the turning point was viewing the installation logs and working through the errors that were reported there. I had not completely removed all the old files, and one of them was causing an error.
If you are installing onto mac using the .dmg file, you can hit Ctrl+L to view the log file, and identify, specifically, what the problems are.
The MySQL portion of this guide worked for me:
Download the “x86, 64bit” DMG version of MySQL 5.6.x for OS X 10.7
from mysql.com and install the pkg, the startup item and the pref
pane.
Open the pref pane and start the MySQL Server.
Update the path by editing ~/.bash_profile and add:
export PATH=~/bin:/usr/local/bin:/usr/local/mysql/bin:$PATH
at top of file.
Set up MySQL root password:
mysqladmin -u root password {new-password}
mysqladmin -u root> -p{new-password} -h localhost password {new-password}
mysqladmin -u root -p{new-password} reload
Clear the history file by typing history -c so that {new-password}
isn’t in plain text on the disk.
Now ensure that the mysql.sock file can be found by PHP: Ensure that
MySQL is running
sudo mkdir /var/mysql sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
This answer on StackOverflow explains it pretty well: https://stackoverflow.com/a/15472270/1067124.
Backup your your /usr/local/mysql/data/ folder first
Delete old installation (this will also remove your data!):
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
sudo rm -rf ~/Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /var/db/receipts/com.mysql.*
Install MySQL from http://dev.mysql.com/downloads/mysql/5.1.html
Restore /usr/local/mysql/data/
OS Yosemite and Maverick has been having these issues to DYLD_LIBRAARY PATH
Found here
Please Use this link to view the answer already on stack overflow.
I see someone has given an answer that works in the original poster's case, but as this is such a common problem I thought I'd post the solution I found to the same problem in my own case.
I thought I knew what I was doing as I had successfully installed MySQL (mysql-5.6.15-osx10.7-x86_64.dmg) on two machines running Mavericks following the procedures at https://discussions.apple.com/docs/DOC-3082, which also allow you to install Perl drivers. However when I tried on a laptop that had previously been running Snow Leopard (sic) I hit the dreaded error message, and although a mysql directory had been generated at /var/mysql/ no socket was generated there or anywhere else.
The problem must have been caused by the previous version of MySQL I had installed, as the solution was to do a complete uninstall (http://johnmcostaiii.net/2011/removing-mysql-osx-lion/) and then reinstall. So if you have a early version of MySQL installed and you hit this problem, this might be the solution. It worked for me.

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

Timeout error occurred trying to start MySQL Daemon. CentOS 5

I ran into troubles with MySQL on my CentOS.
I had some problems and backed up my database and removed mysql with all dependencies.
After that I ran reinstalled:
yum groupinstall "MySQL Database"
Installed without errors.
Running the mysql daemon:
service mysqld start
Timeout error occurred trying to start MySQL Daemon.
Starting MySQL: [FAILED]
I also ran
# /usr/bin/mysql_install_db --user=mysql
Installing MySQL system tables...
120112 1:49:44 [ERROR] Error message file '/usr/share/mysql/english/errmsg.sys' had only 480 error messages,
but it should contain at least 481 error messages.
Check that the above file is the right version for this program!
120112 1:49:44 [ERROR] Aborting
Installation of system tables failed!
Examine the logs in /var/lib/mysql for more information.
You can try to start the mysqld daemon with:
/usr/libexec/mysqld --skip-grant &
and use the command line tool
/usr/bin/mysql to connect to the mysql
database and look at the grant tables:
shell> /usr/bin/mysql -u root mysql
mysql> show tables
Try 'mysqld --help' if you have problems with paths. Using --log
gives you a log in /var/lib/mysql that may be helpful.
The latest information about MySQL is available on the web at
http://www.mysql.com
Please consult the MySQL manual section: 'Problems running mysql_install_db',
and the manual section that describes problems on your OS.
Another information source is the MySQL email archive.
Please check all of the above before mailing us!
And if you do mail us, you MUST use the /usr/bin/mysqlbug script!
Checking the logs:
less /var/log/mysqld.log
Log file is empty. I don't even know how to debug it and not sure what to do.
Any recommendations?
Thank you
I know you asked this a long time ago, but since people who search for "Timeout error occurred trying to start MySQL Daemon." may end up here, there are several possible solutions to that error. Here are some of them:
First, instead of running service mysqld start or service mysqld restart try running:
$ service mysqld stop; mysqld_safe &
There are known problems with the mysqladmin lines in the /etc/init.d/mysqld script.
If this isn't working, try the following things: check if there is enough free disk space (especially in /var):
$ df -h
Check for possible error messages in these files (not all of them may exist):
# tail -n 30 /var/log/messages
# tail -n 30 /var/log/mysqld.log
# tail -n 30 /var/lib/mysql/*.err
# tail -n 30 /var/log/mysql/error.log
Next up, make sure that /etc/my.cnf uses...
socket=/var/lib/mysql/mysql.sock
...and that the directory /var/lib/mysql/ actually exists.
Set the correct permissions and ownerships:
# chown -R mysql.mysql /var/lib/mysql/
# chmod g+w /var/run/mysqld/
# chgrp mysql /var/run/mysqld/
Still not working? Try changing the bind-address in my.cnf to 127.0.0.1 or 0.0.0.0, or comment out that line.
If you're still out of luck, search for more information about mysql_install_db and since your InnoDB database may be broken also look into set-variable=innodb_force_recovery=6.
Hey sometimes it's because you ran out of disk space... so run a cursory df -h to be sure! (This JUST happened to me :P).
Before starting the mysql server rename files /var/lib/mysql/ib_logfile0 and /var/lib/mysql/ib_logfile0 then restart the server
in linux/unix
mv /var/lib/mysql/ib_logfile0 /var/lib/mysql/ib_logfile0_old
mv /var/lib/mysql/ib_logfile1 /var/lib/mysql/ib_logfile1_old
then
service mysqld restart
In my case the cause was that i set key_buffer_size in /etc/my.cnf when i commented it out, mysqld started ok.
Try This:
rm $(grep socket /etc/my.cnf | cut -d= -f2) && service mysqld start

Why do I get "MySQL is not running but lock exists"?

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!