2

So far I've seen that these three commands do the same thing. Which is preferred or does it not matter which command I use?

sudo /etc/init.d/mysql stop

sudo service mysql stop

sudo systemctl disable mysql

Neo
  • 115
  • 1
  • 1
  • 8
  • I'm assuming you meant to put "stop" instead of "disable" on the last one. If so, then all three are aliases for the same thing, but the middle one is the best and most portable. – thomasrutter May 25 '21 at 01:38

1 Answers1

4

If you are using a modern version of MySQL, then the “best” method is the second on your list:

sudo service mysql stop

This does the same as the first, but in a manner consistent with other services on the system, making it easier to remember and work with long term.

Abstain from using the last one. Disabling and stopping are not always synonymous

matigo
  • 22,138
  • 7
  • 45
  • 75
  • In the end, they're all the same. But I prefer systemctl because if I need to run a different action than the normal stop/start/restart commands available via service I would only need to remember one command. This post has mode details on this https://askubuntu.com/a/903360/8698 – Dan May 25 '21 at 09:11