Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I try find in internet some article where describe how correct start -stop mysql server.

I find this article: How to start/stop MySql server on Ubuntu 8.04 | Abhi's Blogging World

I run this command:

/etc/init.d/mysql start 

but i see this error

ERROR 1045 (28000) Access denied for user....

After i try this command:

sudo /etc/init.d/mysql start

enter pass

And again i see the same error.

Next command:

sudo /etc/init.d/mysql - root -p start

In result:

ERROR 1049 (42000) Unknown database 'start'.

And Only I run this command:

sudo service mysql start

MySQL server success started. Cool!

So, what wrong with other command? Why in result error?

share|improve this question
3  
In fact, even with sudo it didn't work for me, but then I found in the script the following hint: Rather than invoking init scripts through /etc/init.d, use the service(8) and it was ok –  Tim Sep 20 '12 at 20:21
    
Tim is correct. Use sudo service mysql start. –  Ed Manet Mar 15 '13 at 18:07

4 Answers 4

up vote 43 down vote accepted

Your first two commands weren't run as root so that is expected behaviour. You need to be root to stop/start mysql.

However:

sudo /etc/init.d/mysql start

should work. Indeed it does, for me:

kojan:~> sudo /etc/init.d/mysql restart
[sudo] password for chris: 
Stopping MySQL database server: mysqld.
Starting MySQL database server: mysqld.
Checking for corrupt, not cleanly closed and upgrade needing tables..

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

sudo /etc/init.d/mysql - root -p start

The arguments are wrong. an init.d script only takes start or stop or restart - 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 using service. The page you link is 3 years old so has to be taken with some salt :)

share|improve this answer
4  
Also try sudo service mysql start –  user108762 Nov 17 '12 at 12:45
    
start mysql worked for me (Ubuntu 12.04.4). –  Tim May 12 at 7:28

Also helps to double check that "mysql" is the correct service name. In my case it wasn't. I kept getting following response: mysql: unrecognized service when running

service mysql status 

Then I checked /etc/init.d and found script named mysqld which listed process name: mysqld and prog=mysqld

So then I did

service mysqld status
service mysqld stop
service mysqld start 

and they all worked fine.

share|improve this answer
    
mysql: unrecognized service –  Green Jul 20 '13 at 1:06
1  
At least on 13.10, you'll need to run it with root privileges. eg, "sudo service mysql status". –  Bryce Mar 4 at 5:09

For Ubuntu 12.10:

START MYSQL:

sudo start mysql

RESTART MYSQL:

sudo restart mysql # The service must be running

STOP MYSQL:

sudo stop mysql # The service must be running
share|improve this answer
1  
stop: Unknown job: mysql –  Green Jul 20 '13 at 1:07
    
@Green I just tried this (one year later) and it is still working. This is my result: mysql stop/waiting. You must know that you have to be already running mysql to stop this ;) –  Lucio Jul 24 '13 at 22:45

Actaully i got a starange error, when i installed mysql-workbench on ubuntu machine. After thatmi tried to start mysql service by this command:

service mysql start

So i got the solution that mysql server was not installed, So i installed it my problem solved. Command to install mysql-server is:

sudo apt-get install mysql-server

After successful installation, start mysql server as:

service mysql start

.

All the best !!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.