MySQL 5.7 stopped working on mac El Capitan - mysql

I upgraded the mysql from 5.5 to 5.7. I was working very well.
Today when I turned on my mac the mysql was not working and I can't start.
I tried to start by LaunchDaemon on system preferences but nothing happens and I tried by this command on terminal:
sudo launchctl load -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
When I run this command I receive this message:
/Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist: service already loaded
but not work...
edit: I have no Idea why, but I restarted my mac and now it's working

first unload
sudo launchctl unload /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
(replaced from onload )
then
sudo launchctl load -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist

I do not know why, but my system automatically renamed the MySQL directory.
I identified that the usr/local/mysql/ directory was now called usr/local/mysql-5.7.21-macos10.13-x86_64/
What I did that solved the problem, was to create a symbolic link
{sudo ln -s mysql-5.7.21-macos10.13-x86_64 mysql}
I rebooted my mac, and everything worked correctly.
you will probably need to identify the new directory name with the command
{ls usr/local}

Related

Unable to stop MySQL on OS X 10.10

I'm starting to go nuts over this.
I setup MySQL/Apache/PHP using the tutorial by Coolest Guides On The Planet.
I'm guessing something went wrong as its not working as expected so I want to uninstall and try again.
The trouble is that I can't stop MySQL either by system preferences or command line. I keep trying suggestions on the net but so far unsuccessful.
Can anyone help?
Finally got around the autostart - Thanks to all who contributed and allowed me to see the way.
To stop the auto start I used:
sudo launchctl unload -w /Library/LaunchDaemons/com.mysql.mysql.plist
And to kill the service I used:
sudo pkill mysqld
This is what worked for me. It was listed under a different plist name:
sudo launchctl unload -w com.oracle.oss.mysql.mysqld.plist
For Mac Users
kill -9 {pid} kept restarting the process. This was because I had MySQL Server running. On OSX I had to:
1- System Preferences.
2- Search for mysql.
3- Press the Stop MySQL Server button.
got it from a github issue, and it solved my problem
https://github.com/docker/compose/issues/4950#issuecomment-407145733
brew services stop mysql#5.6 worked for me, when all else failed.
I also got the same problem, unable to stop MySql Sever through system preferences on macOS High Sierra.
I did brew uninstall mysql on my terminal window.
now I am able stop stop MySql Sever through system preferences.
Since mysql was installed on my mac 2 ways binary as well as home brew.
in terminal
kill `pgrep mysqld`
this kills the mysqld process.
If you used brew then you can find out which version you are using by:
launchctl list|grep mysql
this will print something like
92555 0 homebrew.mxcl.mysql#5.7
In my case I'm using mysql#5.7
You can stop using:
brew services stop mysql#5.7
Try with issuing the following command in command line:
ps -xo pid,ppid,stat,command | grep mysqld
It will show you your processes, with their parent ID in the second column. Look for the mysqld and it's parent process. After locating it, issue a:
sudo kill pid
where pid is mysqld's parent process ID.
EDIT
If you want to stop the process from launching again, try:
sudo launchctl unload /System/Library/LaunchDaemons/mysqld.plist
I've installed mysql via homebrew, but stop mysql by using mysql stop command, mysql restart right now.
try to execute command as follow if your mysql was installed via homebrew
brew services stop $(brew list | grep mysql)

homebrew.mxcl.mysql.plist launchctl load error

I brew installed mysql and want to launchd start mysql at login.
brew install mysql
ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
The brew install was successful, but after the last command, it shows
Could not find domain for
How to resolve this issue?
System info: Mac OS X 10.10 Yosemite, brew installed mysql-5.6.21.
On my other machine (same OS, newer and less used), the above three commends were successful and mysql indeed automatically start after restarting the machine.
The user running the command must be logged in via the GUI. Then, the command will work over both SSH and with a local terminal on the machine.
I had this issue when I was trying to start postgresql after installing it via homebrew, although previously it had worked fine. I later realised that it only failed when run remotely via SSH - when I used a local terminal it began without problems.
Re DanielaWaranie: sudo should not be necessary.
Remove the original plist and create the link again:
$ rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
$ ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
$ brew services start mysql
I had the same issue. For some reason the ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist file was not a symbolic link but a regular file. After removing the file and creating the link again it worked fine.
This error message is missleading. Most common reason for this issue is a permission problem.
Just run it as root:
sudo su
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
I had the same issue on Mac OS X El Capitan when running with a restricted user using a interactive, non-login shell or an interactive, login shell. Works in a sh and bash.

MySQL does not start when upgrading OSX to Yosemite or El Capitan

I know similar questions exist, such as MySQL with MAMP does not work with OSX Yosemite 10.10. However, I do have MAMP, nor XAMPP installed on my computer.
When I try to start mySQL from the PrefPane, nothing happens.
When I try to start mqSQL from the command line via sudo /usr/local/mysql/support-files/mysql.server start I get:
Starting MySQL . ERROR! The server quit without updating PID file
(/usr/local/mysql/data/adamg.local.pid).
Any and all help would be appreciated. I can supply any file output necessary.
Open a terminal:
Check MySQL system pref panel, if it says something along the line "Warning, /usr/local/mysql/data is not owned by 'mysql' or '_mysql'
If yes, go to the mysql folder cd /usr/local/mysql
do a sudo chown -R _mysql data/
This will change ownership of the /usr/local/mysql/data and all of its content to own by user '_mysql'
Check MySQL system pref panel, it should be saying it's running now, auto-magically. If not start again.
Another way to confirm is to do a
netstat -na | grep 3306
It should say:
tcp46 0 0 *.3306 *.* LISTEN
To see the process owner and process id of the mysqld:
ps aux | grep mysql
Long story short you need to create a launch file. So, from Terminal:
sudo vi /Library/LaunchDaemons/com.mysql.mysql.plist
(If you are not familiar with vi, then press i to start inserting text)
This should be the content of your file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true />
<key>Label</key>
<string>com.mysql.mysqld</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/mysql/bin/mysqld_safe</string>
<string>--user=mysql</string>
</array>
</dict>
</plist>
press esc then : wq!enter
Then you need to give the file the right permissions and set it to load on startup.
sudo chown root:wheel /Library/LaunchDaemons/com.mysql.mysql.plist
sudo chmod 644 /Library/LaunchDaemons/com.mysql.mysql.plist
sudo launchctl load -w /Library/LaunchDaemons/com.mysql.mysql.plist
And that is it.
In my case I fixed it doing a little permission change:
sudo chown -R _mysql:_mysql /usr/local/var/mysql
sudo mysql.server start
I hope it helps somebody else...
Note: As per Mert Mertin comment:
For el capitan, it is sudo chown -R _mysql:_mysql /usr/local/var/mysql
Solved by installing the latest mySQL release, following the instructions here http://coolestguidesontheplanet.com/get-apache-mysql-php-phpmyadmin-working-osx-10-10-yosemite/
EDIT
As Yosemite gets more popular, more people are stumbling on this question. The answer above has to do with upgrading MySQL, so that it runs. The answer linked by #doc in the comments has to do with getting MySQL to start automatically. These are 2 separate issues.
Execute the following commands from command line...
sudo launchctl load -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
sudo launchctl unload -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
and then start the mysql server using
sudo /usr/local/mysql/support-files/mysql.server start
The .pid is the processid of the running mysql server instance. It appears in the data folder when mysql is running and removes itself when mysql is shutdown.
If the OSX operating system is upgraded and mysql is not shutdown properly before the upgrade,mysql quits when it started up it just quits because of the .pid file.
There are a few tricks you can try, http://coolestguidesontheplanet.com/mysql-error-server-quit-without-updating-pid-file/ failing these a reinstall is needed.
You just need to create the user mysql (mysql installation script creates _mysql)
sudo vipw
duplicate line that contains _mysql
Change for the duplicated line _mysql to mysql
sudo /usr/local/mysql/support-files/mysql.server start
Starting MySQL
.. SUCCESS!
The re-install fixed it because the installer created a new MySQL instance and the symbolic link to /usr/local/mysql now points to a data directory that does not have an existing pid.
It's worth noting that the mysql prefpane and mysql.server script use the hostname for the pid, so changing the hostname may cause issues with the this.
While the prefpane is out of date, it's a nice GUI for someone to start/stop MySQL even if the auto-start function doesn't work.
I've taken a hybrid approach where I've adapted my MySQL install script to use Launchd to auto-start MySQL, but the plist actually calls the mysql.server script. This way the prefpane can still be used to start/stop MySQL on demand, and trying to do a simple MySQL restart won't be too confusing.
Here is script that just enables this Launchd behavior on Yosemite with MySQL already installed:
https://raw.githubusercontent.com/MacMiniVault/Mac-Scripts/master/mmvMySQL/YosemiteLaunchd.sh
Here is the script that handles the entire automated installation of MySQL:
https://raw.githubusercontent.com/MacMiniVault/Mac-Scripts/master/mmvMySQL/mmvmysql.sh
You will sometimes miss previous data if you try to install new version.. Please use the following in your terminal and I guarantee that mySql will start running in no time..
sudo /Applications/XAMPP/xamppfiles/bin/mysql.server start
Remember, it will ask for your Machine password and not mysql password..
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.
Try this:
sudo mysqld_safe &
Way simplest: copy and paste this into Terminal (but be sure to read more first):
bash <(curl -Ls http://git.io/eUx7rg)
This will install and configure everything automagically. The script is provided by MacMiniVault and is available on Github. More information about the mySQL install script on http://www.macminivault.com/mysql-yosemite/.
you want fix it can edit file "/Applications/XAMPP/xamppfiles/xampp" with TextEdit.
Look for text "$XAMPP_ROOT/bin/mysql.server start > /dev/null &"
And add "unset DYLD_LIBRARY_PATH" on top of it. It should look like:
unset DYLD_LIBRARY_PATH
$XAMPP_ROOT/bin/mysql.server start > /dev/null &
hope can help you
None of the above worked.. but installing a new version of MySQL did the trick.
2 steps solved my problem:
1) Delete "/Library/LaunchDaemons/com.mysql.mysql.plist"
2) Restart Yosemite
I usually start mysql server by typing
$ mysql.server start
without sudo. But in error I type sudo before the command. Now I have to remove the error file to start the server.
$ sudo rm /usr/local/var/mysql/`hostname`.err
My Mac decided to restart itself randomly; causing a whole slew of errors. One of which, was mysql refusing to start up properly. I went through many SO questions/answers as well as other sites.
Ultimately what ended up resolving MY issue was this:
1) Creating the file (/usr/local/mysql/data/.local.pid
2) chmod 777 on that file
3) executing mysql.server start (mine was
located in/usr/local/bin/mysql.server)
Same happened to me! So I tried to startup again after I had terminated the running mysql application, and that worked!

Lost or corrupt mysql table after computer is turned off or restarted

I'm using a mysql local database to store some data from two ruby scripts i created. The problem is that whenever I restart or turn off my computer my database seems to get corrupted as when i tried to access it it show the following error:
Can't connect to MySQL server on 'Andres-MacBook-Air-3.local' (61) (Mysql2::Error)
I then use the following commands (which I found while googling around) to restore the connection:
cd /usr/local/mysql
sudo ./bin/mysqld_safe
(Enter your password, if necessary)
(Press Control-Z)
bg
After I do that, I can connect to the database but when I try to access a table the following error comes up:
Error retrieving table information
An error occurred while retrieving the information for table 'fourCheckins'. Please try again.
MySQL said: Table 'trackpuntos.fourcheckins' doesn't exist
I think that turning off/restarting my computer is causing the problem as this same scenario has happen to be twice. Fortunately after the first time I am doing regular mysqldumps.
Does anyone have an idea on why is this happening/how to prevent it?
I'm running mysql 5.6.12, on a macbook air running OS Lion.
Thanks
I've been having the same problem for the past week. I'm finding the InnoDB databases are getting corrupted when I have open connections to the databases and I shut off/restart the computer.
I had installed mysql 5.6 unintentionally via homebrew upgrade on my Mac. I just rolled mysql back to 5.5.29 following the instructions below. After the downgrade back to 5.5, I set up my databases again, opened a bunch of connections, and then shutdown the computer. Upon reboot, I had no corruptions. Hopefully it'll stay that way!
Note: paths may be different for your system
Uninstall 5.6 mysql via homebrew
$ brew uninstall mysql
$ rm -rf /usr/local/var/mysql
Install 5.5.29 mysql via homebrew
$ cd /usr/local/Library/Formula
$ git checkout -b mysql-5.5.29 336c97637c5449018cde59f7d2a87a298692da08
$ brew install mysql
follow all the post-install steps for mysql...
$ unset TMPDIR
$ mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
$ launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
reset homebrew to master !important!
$ git checkout master
Lastly, don't brew upgrade mysql until 5.6 is more stable!
I had the same problem after a reboot... Just stopped and restarted MySQL and my DB was working fine after that.

mysql.sock is not created OSX

I run mysql on OSX, now when I restart my computer it does not create the mysql.sock, meaning that all my connections gives me a error 2002.
anyone knows how to prevent this?
I had this same issue on Snow Leopard, the socket spawns in the wrong location for some reason on OS X.
To get the socket spawning in the correct location:
create a new file "my.cnf" in /etc with the following lines:
[mysqld]
socket=/var/mysql/mysql.sock
[client]
socket=/var/mysql/mysql.sock
and restart mysqld: sudo /usr/local/mysql/bin/mysqld_safe
This will force the MySQL socket file to spawn in the proper location, and everything should work normally. Good luck!
I use Mac OS 10.12 Sierra, I meet the same mysql question. I can find mysql.sock in my file system.
Resolve question method:
1 remove my.cnf
sudo rm -rf /etc/my.cnf
restart your mysql servers
brew services restart mysql
or
sudo launchctl unload -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
sudo launchctl load -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
you can check it
sudo lost -i tcp:3306
mysql is running ok.
I had that problem on a Linux box once, and I found that the directory (/var/run/mysqld) was not writable by the user mysql runs as. I would check that if I were you.
I recommend to execute
sudo find / -name "mysql.sock"
to be sure the file is not anywhere.
In my cas I used the command mysql with variant socket in this way
mysql --socket=/var/lib/mysql/mysql.sock
I've been having trouble in restarting MySQL on a box running Sierra. Every time that I tried to connect after restarting my machine, I would lose the ability to connect to my MySQL instance. Based on this post, I determined that there was, indeed, no my.cnf file in my environment. I followed DashRantic's instructions to force a build of a socket file. It appears to have resolved the problem.