bash: service: command not found

2

I was having an issue running a mysql command and saw suggestions on a few issues online that suggested using the service command and it seemed to be that it was something that I should have by default.

I had been installing a few homebrew packages, so I'm not sure if that could have caused it? I have never used this command before, so I'm not entirely sure.

Attempting to run the command sudo service mysql start returns

sudo: service: command not found

I have not got much experience using the terminal, so apologies. I saw a lot of comments suggesting that the service command is located in /usr/sbin/ and also possibly /sbin/service but I could not find it in either.

my .bash_profile is as follows

export PATH=~/.composer/vendor/bin:$PATH
export PATH=/usr/local/php5/bin:$PATH
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH=$PATH:/home/user/bin
export PATH=$PATH:/sbin

The two exports at the bottom were from suggestions in other questions but neither seemed to work.

Any ideas? Any help would be greatly appreciated.

mcclosa

Posted 2019-03-08T22:36:01.777

Reputation: 91

Use something like ls /{{s,}bin,usr/{s,}bin}/service to see where service is located - but I fear macos uses a different way to handle services. See e.g. https://serverfault.com/q/194832/453007

– choroba – 2019-03-08T22:41:43.543

@choroba Thanks for the replay, service does not appear in any of the folder, running that command returns ls: /bin/service: No such file or directory ls: /sbin/service: No such file or directory ls: /usr/bin/service: No such file or directory ls: /usr/sbin/service: No such file or directory – mcclosa – 2019-03-08T22:49:40.970

On a recent system mysql is perhaps handled by systemd (on some systems init.d has been totally replaced by systemd, on older systems they still coexist). See if systemctl status mysql* seems to know about mysql, if so mysqlis a systemd service and can be controlled with the systemctl command. – xenoid – 2019-03-08T23:10:25.717

What version of ubuntu are you using? – davidgo – 2019-03-09T01:22:56.303

1@davidgo None of them. The mention of Homebrew makes it clear that the OP is using macOS. – duskwuff -inactive- – 2019-03-13T22:02:34.193

Answers

1

The service command is specific to certain Linux distributions. It is not used on macOS.

If you installed MySQL through Homebrew, you can start and stop it using the commands:

brew services start mysql
brew services stop mysql

duskwuff -inactive-

Posted 2019-03-08T22:36:01.777

Reputation: 3 824