How to stop mysql on OsX from the command line - mysql

This question bas many answers, I tried what I found – did not work
So, I tried sudo mysqld stop.
Still I see the mysql processes running:
0 317 1 0 11:15AM ?? 0:00.02 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/anarinsky-mbp.smartdestinations.com.pid
74 3562 317 0 11:40AM ?? 0:00.41 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/data/anarinsky-mbp.smartdestinations.com.err --pid-file=/usr/local/mysql/data/anarinsky-mbp.smartdestinations.com.pid
The same happens if I do “sudo kill -9 3562”.
Trying to go to /Library/LaunchDaemons does not retrieve any mysql entries
ls /Library/LaunchDaemons | grep mysql
The service command does not work:
-bash: service: command not found
My Os X version is 10.9.2

There are two answers I know, it might not help since you search a long time.
1.if you install mysql from dmg, you can close it in "system preferences".
2.And besides that, you can start/stop/restart mysql by:
sudo /usr/local/mysql/support-files/mysql.server start
sudo /usr/local/mysql/support-files/mysql.server stop
sudo /usr/local/mysql/support-files/mysql.server restart

To install Homebrew, open Terminal/iTerm and run following command or check https://brew.sh/
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Install mysql
$ brew install mysql.
Install brew services first
$ brew tap homebrew/services.
Start mysql
$ brew services start mysql.

In order to avoid mysqld from auto restarting after killed, try execute all these 3 commands:
$ brew services stop mysql
$ sudo launchctl unload /Library/LaunchDaemons/com.mysql.mysql.plist
$ sudo launchctl unload /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist

Related

Cannot Start MYSQL Server Mac

I am currently trying to run mysql server on a mac, but the Start MySQL Server from the preferences pane doesn't work, and neither does starting it from the Terminal. I have found a lot of fixes, but none of them work. This is my first time using MySQL, I have very little (just a bit of Java) programming experience, and this is my first StackOverflow post in a long time (please help me learn if I did it incorrectly!).
I installed this version(didn't use brew): mysql-5.7.21-1-macos10.13-x86_64
My machine is 64 bit
What I've tried:
Uninstalled and reinstalled MySQL using this process:
To uninstall MySQL and completely remove it (including all databases) from your Mac do the following:
Open a terminal window Use mysqldump to backup your databases to text
files! Stop the database server sudo rm /usr/local/mysql sudo rm -rf
/usr/local/mysql* sudo rm -rf /Library/StartupItems/MySQLCOM sudo rm
-rf /Library/PreferencePanes/My* edit /etc/hostconfig and remove the line MYSQLCOM=-YES- rm -rf ~/Library/PreferencePanes/My* sudo rm -rf
/Library/Receipts/mysql* sudo rm -rf /Library/Receipts/MySQL* sudo rm
-rf /private/var/db/receipts/mysql https://community.jaspersoft.com/wiki/uninstall-mysql-mac-os-x
When I open the folder where mysql is installed, I do not have permissions to open the data or keychain folders. So, I decided it was a permissions problem and tried this: Cannot start Mysql on Mac. When I tried to start the server, I got the following error:
sudo /usr/local/mysql/support-files/mysql.server start Starting MySQL
.Logging to '/usr/local/mysql/data/XXXXs-MacBook-Air.local.err'.
/usr/local/mysql/bin/mysqld_safe: line 198: 7892 Trace/BPT trap: 5
nohup /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql
--datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=XXXXs-MacBook-Air.local.err --pid-file=/usr/local/mysql/data/XXXXs-MacBook-Air.local.pid < /dev/null > /dev/null 2>&1 ERROR! The server quit without updating
PID file (/usr/local/mysql/data/XXXXs-MacBook-Air.local.pid).
Tried to check the admin version and got the following error:
XXXXs-MacBook-Air:mysql XXXX$ bin/mysqladmin version mysqladmin:
connect to server at 'localhost' failed error: 'Can't connect to local
MySQL server through socket '/tmp/mysql.sock' (2)' Check that mysqld
is running and that the socket: '/tmp/mysql.sock' exists!
Tried to open /temp/mysql.sock from the command line and got that it does not exist
Tried this:
XXXXs-MacBook-Air:mysql XXXX$ % mysqladmin variables
-bash: fg: %: no such job XXXXs-MacBook-Air:mysql XXXX$ mysqladmin variables
-bash: mysqladmin: command not found
Tried removing my.cnf per this post and restarted the server
sudo rm -rf /etc/my.cnf
sudo /usr/local/mysql/support-files/mysql.server start
Tried these instructions MySql server startup error 'The server quit without updating PID file '
XXXXs-MacBook-Air:mysql XXXX$ ps -ef | grep mysql 501 9173
549 0 11:54PM ttys000 0:00.01 grep mysql
XXXXs-MacBook-Air:mysql XXXX$ kill -9 PID
-bash: kill: PID: arguments must be process or job IDs XXXXs-MacBook-Air:mysql XXXX$ ls -laF /usr/local/var/mysql/ ls:
/usr/local/var/mysql/: No such file or directory
XXXXs-MacBook-Air:mysql XXXX$ ls -laF /usr/local/mysql lrwxr-xr-x
1 root wheel 30 Apr 4 22:44 /usr/local/mysql# ->
mysql-5.7.21-macos10.13-x86_64 XXXXs-MacBook-Air:mysql XXXX$ sudo
chown -R mysql /usr/local/var/mysql/ Password: chown:
/usr/local/var/mysql/: No such file or directory
XXXXs-MacBook-Air:mysql XXXX$ sudo chown -R mysql /usr/local/mysql
XXXXes-MacBook-Air:mysql XXXX$ sudo
/usr/local/mysql/support-files/mysql.server start Starting MySQL
.Logging to '/usr/local/mysql/data/XXXXs-MacBook-Air.local.err'.
/usr/local/mysql/bin/mysqld_safe: line 198: 9327 Trace/BPT trap: 5
nohup /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql
--datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=XXXXs-MacBook-Air.local.err --pid-file=/usr/local/mysql/data/XXXXs-MacBook-Air.local.pid < /dev/null > /dev/null 2>&1 . ERROR! The server quit without updating
PID file (/usr/local/mysql/data/XXXXs-MacBook-Air.local.pid).
XXXXs-MacBook-Air:mysql XXXX$ unset TMPDIR
XXXXs-MacBook-Air:mysql XXXX$ mysql_install_db --verbose
--user=whoami --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
-bash: mysql_install_db: command not found
And now I'm back to this error:
ERROR! The server quit without updating PID file
(/usr/local/mysql/data/XXXXs-MacBook-Air.local.pid).
Please help!
EDITED: I uninstalled and reinstalled with brew. Using these instructions: http://stefan.magnuson.co/articles/osx/reinstalling-mysql-on-osx-with-homebrew/ Now it works.
I uninstalled and reinstalled SQL with Homebrew using these instructions: http://stefan.magnuson.co/articles/osx/reinstalling-mysql-on-osx-with-homebrew/ Now it works.
This small diagnosis worked for me in MAC...
open Your Terminal and use the following command to check all the instances or mysql that are currently running in your machine.
1) ps -ef | grep mysql
If you found any process Id with the above command.
2) sudo kill -9 [PID]
Where [PID] is the process id next to username
now try restarting mysql again using the mysql server pane or go to terminal and type the following command
sudo /usr/local/mysql/support-files/mysql.server start

How to kill mysql started with "mysql_safe" script?

Short version: I started mysql with mysql_safe and I can't kill it.
Long version: Installing an older version of mysql with macport displayed this suggestion:
$ sudo port install mysql55-server
---> Computing dependencies for mysql55-server
---> Fetching archive for mysql55-server
---> Attempting to fetch mysql55-server-5.5.49_0.darwin_14.noarch.tbz2 from https://packages.macports.org/mysql55-server
---> Attempting to fetch mysql55-server-5.5.49_0.darwin_14.noarch.tbz2.rmd160 from https://packages.macports.org/mysql55-server
---> Installing mysql55-server #5.5.49_0
---> Activating mysql55-server #5.5.49_0
If this is a new install you might want to run:
$ sudo -u _mysql /opt/local/lib/mysql55/bin/mysql_install_db
Running that gave these instructions:
$ sudo -u _mysql /opt/local/lib/mysql55/bin/mysql_install_db
Installing MySQL system tables...
161102 13:15:44 [Note] /opt/local/lib/mysql55/bin/mysqld (mysqld 5.5.49) starting as process 54176 ...
OK
Filling help tables...
161102 13:15:44 [Note] /opt/local/lib/mysql55/bin/mysqld (mysqld 5.5.49) starting as process 54180 ...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/opt/local/lib/mysql55/bin/mysqladmin -u root password 'new-password'
/opt/local/lib/mysql55/bin/mysqladmin -u root -h myusername password 'new-password'
Alternatively you can run:
/opt/local/lib/mysql55/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /opt/local ; /opt/local/lib/mysql55/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /opt/local/mysql-test ; perl mysql-test-run.pl
Please report any problems at http://bugs.mysql.com/
At this point I (unwisely, it seems) ran:
$ cd /opt/local ; /opt/local/lib/mysql55/bin/mysqld_safe &
Now I cannot figure out how to stop the mysql and/or daemondo process(es):
$ ps aux | grep mysql55
myusername 54937 0.1 0.0 2432772 660 s001 R+ 1:39PM 0:00.00 grep mysql55
_mysql 54888 0.0 0.1 2667884 6340 ?? S 1:36PM 0:00.12 /opt/local/lib/mysql55/bin/mysqld --user=_mysql
root 54885 0.0 0.0 2479468 700 ?? Ss 1:36PM 0:00.00 /opt/local/bin/daemondo --label=mysql55-server --start-cmd /opt/local/lib/mysql55/bin/mysqld --user=_mysql ; --pid=exec
I've tried many variations of kill, targeting both mysql (which seems pointless) and daemondo, including (but not limited to) the following:
sudo kill -9 54888 // killing the mysql process results in a new pid
sudo kill 54885 // the doemondo process
sudo kill -SIGHUP 54885
sudo killall mysqld_safe
sudo kill -9 54822 // a reincarnation of the doemondo process
sudo mysqladmin shutdown
For centos or mint
/usr/bin# initctl
for ubuntu
pkill mysqld

Trouble reinstalling mysql on OSX Mavericks

I'm trying to reinstall mysql on my computer (os x mavericks) and I've done the following with the following errors:
bash <(curl -Ls http://git.io/eUx7rg)
Error:
Starting MySQL
... ERROR! The server quit without updating PID file (/usr/local/mysql/data/christians-mbp.saumag.edu.pid).
/usr/local/mysql/support-files/mysql.server: line 362: pidof: command not found
/dev/fd/63: line 119: SORRY, MySQL IS NOT RUNNING ... THERE MUST BE A PROBLEM: command not found
So I decided to see uninstall it if it was already there:
brew uninstall mysql
bash <(curl -Ls http://git.io/eUx7rg)
This says that mysql is currently still installed, so I did the following:
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
edit /etc/hostconfig and remove the line MYSQLCOM=-YES-
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /var/db/receipts/com.mysql.*
bash<(curl -Ls http://git.io/eUx7rg)
This gave me the same error messages as before, So I decided to redo all the rm commands above, including the edit and run the following commands:
ps -ax | grep mysql
brew cleanup
sudo rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
sudo rm -rf /Library/StartupItems/MySQLCOM
brew doctor
brew update
brew install mysql
unset TMPDIR
mysql_install_db --verbose --user=`yyttr3` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
After the last command I got the following error message:
dyld: Library not loaded: ##HOMEBREW_PREFIX##/opt/openssl/lib/libssl.1.0.0.dylib
Referenced from: /usr/local/opt/mysql/bin/my_print_defaults
Reason: image not found
FATAL ERROR: Neither host 'christians-mbp.saumag.edu' nor 'localhost' could be looked up with
/usr/local/opt/mysql/bin/resolveip
Please configure the 'hostname' command to return a correct
hostname.
If you want to solve this at a later stage, restart this script
with the --force option
I don't really know what the problem is, i'm not sure if i'm even installing it right. From what I have read this should be a good way to install mysql. If you have any ideas on what I would greatly appreciate it.
I'm sure you've solved this by now, but I just had the same problem. For anyone else who stumbles across this:
For me, it was an issue with OpenSSL.
resolveip `hostname`
If it says OpenSSL isn't loaded,
brew uninstall openssl
brew install openssl
then try again. Hope this helps.
I had the same problem. Only solution that I found is to install mysql from source code. The reason for this error to occur and how to solve it is explained in full detail in the following link: http://jaitechwriteups.blogspot.com.au/2010/08/mysql-installation-error-neither-host.html
All I had to do was agree XCODE terms by opening XCODE. That fixed everything.

How to stop mysqld

To find out the start command for mysqld (using a mac) I can do:
ps aux|grep mysql
I get the following output, which allows me to start mysql server.
/usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=...
How would I find the necessary command to stop mysql from the command line?
Try:
/usr/local/mysql/bin/mysqladmin -u root -p shutdown
Or:
sudo mysqld stop
Or:
sudo /usr/local/mysql/bin/mysqld stop
Or:
sudo mysql.server stop
If you install the Launchctl in OSX you can try:
MacPorts
sudo launchctl unload -w /Library/LaunchDaemons/org.macports.mysql.plist
sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql.plist
Note: this is persistent after reboot.
Homebrew
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
Binary installer
sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop
sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
sudo /Library/StartupItems/MySQLCOM/MySQLCOM restart
I found that in: https://stackoverflow.com/a/102094/58768
There is an alternative way of just killing the daemon process by calling
kill -TERM PID
where PID is the value stored in the file mysqld.pid or the mysqld process id which can be obtained by issuing the command ps -a | grep mysqld.
I did it with next command:
sudo killall mysqld
I found the answer here.
Use
sudo stop mysql
For Windows, you can run this command directly if mysql/bin is in your path.
mysqladmin -u root -p shutdown
Worked for me on mac
a) Stop the process
sudo launchctl list | grep -i mysql
If the result shows anything like: "xxx.xxx.mysqlxxx"
sudo launchctl remove xxx.xxx.mysqlxxx
Example:
sudo launchctl remove org.macports.mysql56-server
b) Disable to autostart the process
sudo launchctl unload -wF /Library/LaunchDaemons/xxx.xxx.mysqlxxx.plist
Example:
sudo launchctl unload -wF /Library/LaunchDaemons/org.macports.mysql56-server.plist
Finally reboot your mac
Note: In some cases if you tried "a)" first, you need to reboot again before try b).
When mysql was installed with Homebrew, it automatically restarts when killed. You need to use the following command:
brew services stop mysql
PS: If you installed a specific version, it will be mysql#X.X
On OSX 10.8 and on, the control for MySQL is available from the System Configs. Open System Preferences, click on Mysql (usually on the very bottom) and start/stop the service from that pane. https://dev.mysql.com/doc/refman/5.6/en/osx-installation-launchd.html
The plist file is now under /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
for Binary installer use this:
to stop:
sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop
to start:
sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
to restart:
sudo /Library/StartupItems/MySQLCOM/MySQLCOM restart
Try killing mysqld four times in a row. It's the only thing that worked for me...
root#ubuntu:/etc/init# killall -KILL mysqld
root#ubuntu:/etc/init# killall -KILL mysqld
root#ubuntu:/etc/init# killall -KILL mysqld
root#ubuntu:/etc/init# killall -KILL mysqld
mysqld: no process found
Just keep killing it over and over until you see "mysqld: no process found".
Kill is definitly the wrong way! The PID will stay, Replicationsjobs will be killed etc. etc.
STOP MySQL Server
/sbin/service mysql stop
START MySQL Server
/sbin/service mysql start
RESTART MySQL Server
/sbin/service mysql restart
Perhaps sudo will be needed if you have not enough rights
What worked for me on CentOS 6.4 was running service mysqld stop as the root user.
I found my answer on nixCraft.
/etc/init.d/mysql stop
service mysql stop
killall -KILL mysql mysqld_safe mysqld
When you see the following information, you success
mysql: no process found
mysqld_safe: no process found
mysqld: no process found
I use this to solve the installation problem of MySQL 5.6 in Ubuntu 15.10 using this link.
During this installation, I encounter the problem saying:
"mysqld_safe A mysqld process already exists"
Just completely stop the mysqld, mysqld_safe, mysql solves the problem.
If my mysql keeps restarting
sudo rm -rf /usr/local/var/mysql/dev.work.err
mysql.server stop
worked for me.
To stop autostart of mysql on boot, the following worked for me with mysql 8.0.12 installed using Homebrew in macOS Mojave 10.14.1:
rm -rf ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
To stop MariaDB and MySQL server instance:
sudo mysqladmin shutdown
To start MariaDB and MySQL server instance:
mysqld &
To change data ownership for MariaDB and MySQL server instance:
sudo chown -R 755 /usr/local/mariadb/data
Just go to task manager.
Then in process, search mysqld.
right click on mysqld then click on stop.
with this process you can stop it without using commands.
first try this
sudo service apache2 stop
if not, then
sudo mysql stop
if not, then
sudo stop mysql
if not, then
sudo mysqladmin shutdown
I have been there, and I do with many tips, at the end of using tips that I follow will lead me to solved. So if you not solve in this issue, you just do other tips, till your issue get solved. Hopefully it's will help you. Thanks
For mysql 5.7 downloaded from binary file onto MacOS:
sudo launchctl load -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
sudo launchctl unload -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
Following worked for me on my macbook pro:
brew services stop mysql
Incase if you want to stop all brew services:
brew services stop --all
if all else fails, this help me. Every time I tried to kill the process with the last installation it will respawn.
sudo rm -rf /usr/local/var/mysql
brew reinstall mysql
For MAMP
Stop servers (but you may notice MySQL stays on)
Remove or rename /Applications/MAMP/tmp/mysql/ which holds the mysql.pid and mysql.sock.lock files
When you go back to Mamp, you'll see MySQL is now off. You can "Start Servers" again.

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