[mysql] 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?

This question is related to mysql macos

The answer is


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

For Windows, you can run this command directly if mysql/bin is in your path.

mysqladmin -u root -p shutdown

What worked for me on CentOS 6.4 was running service mysqld stop as the root user.

I found my answer on nixCraft.


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

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

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


When mysql was installed with Homebrew, the following command did the trick for me:

brew services stop mysql

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".


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


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

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

I found the answer here.

Use

sudo stop mysql

If my mysql keeps restarting
sudo rm -rf /usr/local/var/mysql/dev.work.err
mysql.server stop
worked for me.


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


For MAMP

  1. Stop servers (but you may notice MySQL stays on)
  2. Remove or rename /Applications/MAMP/tmp/mysql/ which holds the mysql.pid and mysql.sock.lock files
  3. When you go back to Mamp, you'll see MySQL is now off. You can "Start Servers" again.

/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.


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).


Examples related to mysql

Implement specialization in ER diagram How to post query parameters with Axios? PHP with MySQL 8.0+ error: The server requested authentication method unknown to the client Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver' phpMyAdmin - Error > Incorrect format parameter? Authentication plugin 'caching_sha2_password' is not supported How to resolve Unable to load authentication plugin 'caching_sha2_password' issue Connection Java-MySql : Public Key Retrieval is not allowed How to grant all privileges to root user in MySQL 8.0 MySQL 8.0 - Client does not support authentication protocol requested by server; consider upgrading MySQL client

Examples related to macos

Problems with installation of Google App Engine SDK for php in OS X dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.62.dylib error running php after installing node with brew on Mac Could not install packages due to an EnvironmentError: [Errno 13] How do I install Java on Mac OSX allowing version switching? Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) Can't compile C program on a Mac after upgrade to Mojave You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory. (mac user) How can I install a previous version of Python 3 in macOS using homebrew? Could not install packages due to a "Environment error :[error 13]: permission denied : 'usr/local/bin/f2py'"