mysql won't start for xampp for mac users - mysql

======
Mysql cannot start, i am thinking maybe it was conflict with other mysql i have install in my computer.
How to properly config mysql?
I have tried to kill the mysql task, or sudo start it in my terminal

The following steps worked for me, assuming you are using Yosemite:
Step 1.
Delete \Applications\Xampp
Step 2.
Delete usr\local\var\mysql folder
Step 3.
Reinstall Xampp 5.5.19.
Step 4. Run the following commands in terminal to kill the processes, then restart the servers in Xampp.
sudo killall httpd
sudo killall mysqld

Related

How to install and start MySQL 5.7 on macOS BigSur (Apple Silicon) with Homebrew?

I need a specific version of MySQL (5.7) to be installed on my MacBook with M1.
I'm trying to do that with Homebrew.
brew install mysql#5.7
The output:
We've installed your MySQL database without a root password. To secure it run:
mysql_secure_installation
MySQL is configured to only allow connections from localhost by default
To connect run:
mysql -uroot
mysql#5.7 is keg-only, which means it was not symlinked into /opt/homebrew, because this is an alternate version of another formula.
If you need to have mysql#5.7 first in your PATH, run: echo 'export PATH="/opt/homebrew/opt/mysql#5.7/bin:$PATH"' >> ~/.zshrc
For compilers to find mysql#5.7 you may need to set: export LDFLAGS="-L/opt/homebrew/opt/mysql#5.7/lib" export CPPFLAGS="-I/opt/homebrew/opt/mysql#5.7/include"
To have launchd start mysql#5.7 now and restart at login: brew services start mysql#5.7 Or, if you don't want/need a background service you can just run: /opt/homebrew/opt/mysql#5.7/bin/mysql.server start
Right after that, I try to run:
echo 'export PATH="/opt/homebrew/opt/mysql#5.7/bin:$PATH"' >> ~/.zshrc
source .zshrc
mysql_secure_installation
And get the error:
Securing the MySQL server deployment.
Enter password for user root:
Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Also, I've tried:
brew services start mysql#5.7
And also get the error:
Error: Permission denied # rb_sysopen - /Users/vivanc/Library/LaunchAgents/homebrew.mxcl.mysql#5.7.plist
Seems like there is a permissions-related problem.
Any advice is appreciated.
If you are running into issues like "Can't connect to local MySQL server through socket '/tmp/mysql.sock'" or "The post-install step did not complete successfully MySQL", and you installed a previous version of mysql (e.g. 8.x) previously, you may have been at the point where you need to clean everything before reinstalling your preferred version of mysql#x.x.
If you've already visited these to links:
Uninstall all those broken versions of MySQL and re-install it with Brew on Mac Mavericks (Coderwall) + Install MySQL 5.7 on macOS using Homebrew (github) and your're still having trouble with starting your mysql-service, you should try to also remove also /opt/homebrew/etc/my.cnf file.
Remove it together with all the related files too! Summary for an M1 Apple Silcion machine, after uninstalling via brew uninstall mysql or brew uninstall mysql#x.x, please remove:
/opt/homebrew/var/mysql
/opt/homebrew/etc/my.cnf
After this, everything worked like a fresh install (for me). Hope this saved someone's time.
While this question is specific to Apple Silicon and mysql 5.7, and I will address that in this answer, I would like to start by adding some general notes to save others time:
Homebrew supports mysql 5.7 for both intel and apple silicon.
https://formulae.brew.sh/formula/mysql#5.7
Homebrew supports mysql 5.6 for the intel chip, but not apple silicon:
https://formulae.brew.sh/formula/mysql#5.6
If you need 5.6 on apple silicon, it's probably a good idea to just settle with 5.7 since production will need to be upgraded eventually and the differences aren't that big.
In my situation I originally did brew install mysql and it gave me the latest mysql (currently 8.0). When I tried going back over it and doing brew install mysql#5.6, of course this didn't work due to not being supported on the m1 max (apple silicon). I ran into issues then trying to get brew install mysql#5.7 working. I followed some guides mentioning various suggestions. After playing with it for a while, it seems that running two versions of mysql at once will corrupt your mysql files and make it hard to work with and confuse homebrew.
I came across these guides:
brew install mysql on macOS
https://coderwall.com/p/os6woq/uninstall-all-those-broken-versions-of-mysql-and-re-install-it-with-brew-on-mac-mavericks
https://www.codegrepper.com/code-examples/shell/brew+uninstall+mysql
Before reading further, note that in my situation, I had a zip available for my whole local mysql database needs and could risk destroying what I have.
Warning! Reading further and executing these commands carelessly may delete your mysql storage. Make sure you have a backup.
brew remove mysql is a good command that got rid of my latest install.
I also needed brew remove mysql#5.7 even though this is the version I'm trying to install, but they were stepping on each other's foot...
brew cleanup is nice, I noticed it freed up some lock files.
I don't recall having any luck with:
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
but you can try it.
rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist has worked for me.
But note there will also be another file in there for your 5.7 setup.
I'd recommend:
cd ~/Library/LaunchAgents/ then look around to see if you have any mysql* in there. Then if you do, such as homebrew.mxcl.mysql#5.7.plist, then remove it.
These are some that worked for me:
sudo rm -rf /usr/local/var/mysql
rm /usr/local/etc/my.cnf
rm /usr/local/etc/my.cnf.default
Also:
cd opt/homebrew/var
Then if you notice a mysql directory in there, remove it.
It's possible you might have docker or something else similar also running mysql or mysqld.
ps -ax | grep "[m]ysql"
(Note the brackets and quotes in the above is to prevent the grep from showing up in the process list and matching itself unlike the lazier version: ps -ax | grep mysql which will give the impression there's an extra mysql process running)
Once you're ready, please run:
brew services list
double-check you don't have mysql in there.
Then double check you don't have any mysql process running:
ps -ax | grep "[m]ysql"
This can happen for example if you enter mysqld for example....
You might need to do brew services stop mysql or brew services stop mysql#5.7 or similar and repeat steps if you see anything on the service list or process list.
Finally, you should be ready for a fresh install.
The fresh installation process should be rather straight forward:
brew install mysql#5.7
brew link --force mysql#5.7
brew services start mysql#5.7
Then run brew services list to make sure your installation worked correctly.
If you see it's green and "started", your installation was successful!
You should also run:
mysql_secure_installation
Then choose a password for root and go through the list of questions like validation, etc.
Once you're installed, you might also run into mysql mode issues.
cd /opt/homebrew/etc and you should find a my.cnf file.
Edit it using either vim or nano.
You should see something like:
# Default Homebrew MySQL server config
[mysqld]
# Only allow connections from localhost
bind-address = 127.0.0.1
Edit it and set the mysql mode. For example, I don't want the no_zero_in_date mode, so I use:
# Default Homebrew MySQL server config
[mysqld]
# Only allow connections from localhost
bind-address = 127.0.0.1
sql-mode="ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
Then restart mysql like so:
brew services restart mysql#5.7
Then double check you still have a green status "started":
brew services list
If you do, then you should have the no_zero_in_date mode disabled.
You can test it with a query:
SELECT ##sql_mode;
You should now have mysql 5.7 running on Apple Silicon and have the sql_mode set.
If you run into more troubleshooting, do your best to get into a known state such as uninstalled, doing a fresh install, or already installed with some version, etc.
I solved it after hours of searching, it was because I had not cleaned everything regarding my previous MySQL 8.X installation. I followed this and got suspicious when I realized I don't have most of the folders there. I then did a search for all folders named mysql on my computer and found a mysql folder in opt/homebrew/var. After removing it, reinstalling MySQL 5.7, and starting the server everything is working as expected.
When setting up my Apple M1 Macbook Pro I was experiencing the issue of the following error message being thrown:
Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
My fix was to modify the MySQL config file:
nano /usr/local/etc/my.cnf
Append the following lines:
tmpdir=/tmp
user=root
Then run:
brew services restart mysql#5.7
This fixed my issue, and I was then able to connect successfully with my DB client.
Seems like I found the solution (or workaround).
After installing the MySQL 5.7 with Homebrew just run:
mysql.server start
MySQL is started and then you are able to run mysql_secure_installation and mysql commands.
I got this warning:
You should change the ownership of these directories to your user.
sudo chown -R $(whoami) /usr/local/share/doc /usr/local/share/man /usr/local/share/man/man1
And make sure that your user has write permission.
chmod u+w /usr/local/share/doc /usr/local/share/man /usr/local/share/man/man1
I run those two command then it works.

Uninstall MySQL from macOS

Trying to unistall MySQL completely but can see 'grep mysql' process after reboot. Can not kill that process its changing PID. Any suggestions?
To stop the services you can use one of these:
brew services stop mysql
mysql.server stop
Then you can uninstall it with brew uninstall mysql. But database files will remain, so to clear them just do rm -rf /usr/local/var/mysql
Cheers.

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)

Unable to start MySQL CLOUD9

I can not start MySQL on cloud 9.
If I execute:
sudo mysql-ctl status
I get: MySQL is stopped
But if I execute:
sudo mysql-ctl start
It doesn't make nothing, and MySQL keep stopped.
I don't know what to do because I can not reboot. Some ideas?
Thanks!
mysql-ctl install
then
mysql-ctl cli

How make mysql start automatically ? (linux-cli only)

How can i make mysql start every time the system boot ? I need that in a dedicated server(ubuntu distro) in which i have my blog, but every time the server goes down, on booting mysql is stopped.
Btw i can use only command line.
update-rc.d allows setting init script links on Ubuntu and Debian Linux systems to control what services are run by init when entering various runlevels. It should be able to add mysql to the list of services to run at boot:
sudo update-rc.d mysql defaults
If you later want to disable running mysql on bootup:
sudo update-rc.d mysql remove
You can do it by using sysv-rc-conf, on debian based you can install it with sudo apt-get install sysv-rc-conf
then you can choose what start at boot with a simple X on the name of the deamon, all via command line
Run the following command to see your mysql current status:
/sbin/chkconfig mysqld --list
it will return a line such as below:
mysqld 0:off 1:off 2:off 3:off 4:off 5:off 6:off
to make mysql start every time the system boots, type the following:
sudo /sbin/chkconfig mysqld on
Result now from '--list' is:
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
No answer helped. Finally chkconfig and update-rc.d did not work with MySQL on my machine.
Solution, I had a file /etc/init/mysql.override which contained
manual
i just deleted that file
$ sudo rm /etc/init/mysql.override
Deleting
/etc/init/mysql.override
did the job in my case (HostEurope VPS with Ubuntu 12.04)
I had the same problem, so I checked how I disabled it in the first place:
https://askubuntu.com/questions/138487/how-to-keep-apache-and-mysql-from-starting-automatically
Check your /etc/init/mysql.conf to make sure you don't have start on commented out (like I did).
# MySQL Service
description "MySQL Server"
author "Mario Limonciello <superm1#ubuntu.com>"
start on runlevel [2345]
stop on starting rc RUNLEVEL=[016]
...
Rebooted the machine and it works.
$ sudo service mysql status
mysql start/running, process 972
Use the chkconfig command as per the manpage http://manpages.ubuntu.com/manpages/maverick/man8/chkconfig.8.html
Another place to look for clues as to what is and isn't starting at boot time...
/etc/init.d/.depend.start (and its buddy at shutdown time, .depend.stop)
Here's a little more info http://www.pyenet.co.nz/2-202-1-customising-system-startup-and-boot-processes/
I had 2 servers - after booting, 1 would have mysql running, the other not so much.
On the box where mysql was starting at boot time:
chkconfig wasn't even installed
there were zero links from any scripts in /etc/rc?.d/* back to /etc/init.d/mysql
BUT... /etc/init.d/.depend.start contained:
TARGETS = halt apache2 umountfs umountnfs.sh sendsigs networking umountroot reboot killprocs unattended-upgrades urandom mysql mdadm dns-clean landscape-client pppd-dns sysstat rsync sudo postfix single grub-common ondemand rc.local
INTERACTIVE = apache2
postfix: mysql
single: killprocs dns-clean pppd-dns
grub-common: apache2 unattended-upgrades postfix mysql mdadm dns-clean landscape-client pppd-dns sysstat rsync sudo
ondemand: apache2 unattended-upgrades postfix mysql mdadm dns-clean landscape-client pppd-dns sysstat rsync sudo
rc.local: apache2 unattended-upgrades postfix mysql mdadm dns-clean landscape-client pppd-dns sysstat rsync sudo
When I simply copied this file over to the problem server, and rebooted, mysql was up & running.
With Debian 9, I installed MySQL today and typed "reboot" and mysqld restarted automatically. Also rebooted from my VPS dashboard, mysqld restarted automatically. In short, if you have Debian 9, there's nothing extra to do, it just works.