Start & Stop MySQL Server (SSMS)



AVAILABLE:    5

I tried to find articles explaining the correct way to start and stop the MySQL server.

I came across 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 encountered this error:

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


Then, I tried this command:

sudo /etc/init.d/mysql start


I entered my password, and again, I saw the same error.

The next command:

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


produced this result:

ERROR 1049 (42000) Unknown database 'start'.


And when I ran this command:

sudo service mysql start


The MySQL server started successfully.

So, what’s wrong with the other commands? Why do they result in errors?

Solution

The first two commands were not run as root, which is why they didn’t work as expected. You must have root privileges to stop/start MySQL.

However:

sudo /etc/init.d/mysql start


should work. For example, on my system:

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 instead of start because the server was already running, but the result is the same. Are you sure you entered the password correctly? 🙂 Have you edited your sudo config in a way that might block this from working?

As for this command:

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


The arguments are incorrect. The init.d script only accepts single-word arguments like startstop, or restart. You cannot pass multiple arguments as you attempted.

In any case, the short answer is that the correct and recommended way to start MySQL is by using the service command. Over time, service is replacing all init.d scripts, so it’s better to get used to using it.

The page you linked was written in 2008, so take its advice with a grain of salt. 🙂


Post a Comment

Previous Next

نموذج الاتصال