In this post, we are going to see how to start, stop, and restart MySQL Server on macOS, Linux, and Windows. 1. On Mac You can start/stop/restart MySQL Server via the command line.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
- For the MySQL version 5.7 and newer:
sudo launchctl load -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
sudo launchctl unload -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
- Or you can turn it on/off via the macOS Preference Panel
There’s another way which you can use DBngin, an free utility to install and manage multiple database servers on Mac.
- To turn on/off, it’s just one click away from the server control panel:
2. On Linux
- 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
3. On Windows
- Open Run Window by
Winkey + R
- Type
services.msc
- Search MySQL service based on version installed.
- Click stop, start or restart the service option.
Or you can start/stop MySQL from the command prompt:
C:\> "C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld"
C:\> "C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqladmin" -u root shutdown
Need a good GUI tool for MySQL on MacOS and Windows? TablePlus is a modern, native tool with an elegant GUI that allows you to simultaneously manage multiple databases such as MySQL, PostgreSQL, SQLite, Microsoft SQL Server and more.
Download TablePlus for Mac. It’s free anyway!
Not on Mac? Download TablePlus for Windows.
Đã đăng vào thg 5 4, 2021 3:05 CH 1 phút đọc
1. Download
- Hôm nay xin giới thiệu cho các bạn cách Cài đặt MySQL theo cách thủ công cho Windows. Đầu tiên các bạn download MySQL tại //downloads.mysql.com/archives/community/
- Bạn có thể chọn version 5.x hoặc 8.x
- Download MySQL file .zip về và giải nén vào thư mục vd: mysql-v8
2. Khởi tạo database MySQL lần đầu
cd mysql-v8/bin
3. Start MySQL và change password cho user root
Để start MySQL bạn dùng lệnh như sao
cd mysql-v8/bin
mysqld.exe
Giữ cmd window đó và mở thêm cmd window mới và dùng lệnh
mysql -u root -p
nhấn enter và nhập password mặc ở step 2
- Màn hình khi đăng nhập thành công
- Sau đó bạn tiến hành đổi password cho user root bạn dùng lệnh ALTER
> ALTER USER 'root'@'localhost' IDENTIFIED BY '';
4. Kết
Mysql Không có lệnh stop, nếu bạn muốn stop thì kill process nó nhé trong task manager hay bạn có thể tạo batch script start/stop cho MySQL
Done, Chúc các ban thành công.
All rights reserved
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?
asked Jun 18, 2012 at 21:33
David542David542
103k158 gold badges442 silver badges749 bronze badges
4
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: //stackoverflow.com/a/102094/58768
answered Jun 18, 2012 at 21:36
21
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
.
answered Jan 10, 2013 at 0:25
PiroozPirooz
1,22813 silver badges24 bronze badges
7
I did it with next command:
sudo killall mysqld
answered Jul 31, 2017 at 8:14
answered Dec 31, 2014 at 5:54
bb94bb94
1,2761 gold badge11 silver badges21 bronze badges
3
For Windows, you can run this command directly if mysql/bin is in your path.
mysqladmin -u root -p shutdown
Pang
9,213146 gold badges85 silver badges118 bronze badges
answered Dec 21, 2015 at 9:27
0
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].
answered Aug 16, 2018 at 13:00
ceskamxceskamx
2262 silver badges4 bronze badges
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. //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
answered Jun 23, 2016 at 14:15
ppostma1ppostma1
3,5281 gold badge26 silver badges28 bronze badges
3
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
answered Nov 13, 2020 at 12:38
BertCBertC
1,50718 silver badges27 bronze badges
2
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
answered Aug 4, 2012 at 12:42
Steven LizarazoSteven Lizarazo
5,1702 gold badges27 silver badges25 bronze badges
0
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".
answered Jun 1, 2019 at 14:11
arnoldbirdarnoldbird
8311 gold badge12 silver badges30 bronze badges
2
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
answered Dec 18, 2014 at 8:45
What worked for me on CentOS 6.4 was running service mysqld stop
as the root user.
I found my answer on nixCraft.
answered Jan 5, 2014 at 22:12
J.W.F.J.W.F.
6102 gold badges10 silver badges24 bronze badges
1
/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.
Rajan
5916 silver badges17 bronze badges
answered May 13, 2016 at 4:12
If my mysql keeps restarting
sudo rm -rf /usr/local/var/mysql/dev.work.err
mysql.server stop
worked for me.
answered Jan 18, 2018 at 6:15
portatlasportatlas
5404 silver badges9 bronze badges
1
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
answered Dec 2, 2018 at 23:56
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
Giacomo1968
25.2k11 gold badges69 silver badges97 bronze badges
answered Apr 15, 2019 at 13:31
- 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.
answered May 5, 2021 at 4:55
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
answered Mar 10 at 17:29
ahmahm
1091 silver badge8 bronze badges
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
answered Jan 25, 2019 at 22:54
ehacinomehacinom
6,8905 gold badges40 silver badges62 bronze badges
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
answered Jan 5, 2021 at 10:40
Rajeev JayaswalRajeev Jayaswal
1,2731 gold badge18 silver badges21 bronze badges
For MAMP
- Stop servers [but you may notice MySQL stays on]
- Remove or rename
/Applications/MAMP/tmp/mysql/
which holds themysql.pid
andmysql.sock.lock
files - When you go back to Mamp, you'll see MySQL is now off. You can "Start Servers" again.
answered Dec 20, 2018 at 15:43
kevnkkevnk
18.3k3 gold badges26 silver badges26 bronze badges
1