I tried to find in some articles describing how to correctly start & stop mysql server.
I found this link: How to start/stop MySql server on Ubuntu 8.04 | Abhi's Blogging World
I ran this command:
/etc/init.d/mysql start
but I see this error
ERROR 1045 (28000) Access denied for user....
After I tried this command:
sudo /etc/init.d/mysql start
I entered my password, and again I see the same error.
Next command:
sudo /etc/init.d/mysql - root -p start
results in:
ERROR 1049 (42000) Unknown database 'start'.
And when I run this command:
sudo service mysql start
MySQL server success started. Cool!
So, what's wrong with the other commands? Why do they result in error?
Best Answer
Your first two commands weren't run as root so that is expected behaviour. You need to be root to stop/start mysql.
However:
should work. Indeed it does, for me:
I used restart rather than start, since it was already running, but the effect is the same. Are you sure you entered your password correctly? :) Have you edited your sudo config at all which would stop this working?
This one..
The arguments are wrong. an init.d script only takes
start
orstop
orrestart
- just one word telling it what to do. You cannot give it multiple arguments as you were trying to do.Anyway, the short answer is the one you actually got to work, is the recommended way.
service
is replacing all the init.d scripts over time, so you should get into the habit of usingservice
. The page you link is 3 years old so has to be taken with some salt :)