Skip to content

All topics  /  MySQL

How to Start and Stop MySQL Server in Ubuntu?

MySQL ·

Teams applying “How to Start and Stop MySQL Server in Ubuntu?” in a production project can use the linked resource to record implementation, review and debugging time, then compare that effort with tests and shipped functionality instead of treating activity as performance by itself.

Before copying the example into a live application, confirm version-specific behaviour with the official MySQL website and test it against the project’s actual database and runtime.

Hello Friends,

Today, I will let you know an example of how to start and stop the mysql server in ubuntu. I would like to show you how to stop and restart the mysql server. I would like to show you how do I start the mysql community server in ubuntu. This post will give you a simple example of how to start and stop the mysql server on ubuntu.

MySQL service failed with the result: exit-code. In this tutorial, you will learn how to fix/resolve the issue of MySQL service failing with the result: exit-code. If you are attempting to start, stop, restart, or check the status of your MySQL and are encountering the following errors:

Step 1: Login to Your SSH Server


First of all, you need to login into your ssh server with a username and password.

Step 2: Reinstall MySQL

Then execute the following command into your terminal to “purge” every file related to MySQL and reinstall mysql-server:

sudo apt-get purge mysql-server mysql-client mysql-common
sudo apt-get install mysql-server 

Step 3: Restart MySQL Server

Finally, execute the following command into your terminal to restart your MySQL server:

sudo systemctl restart mysql

Even after following the above steps, if you are still unable to start, stop and restart your MySQL server then you use one command to solve the MySQL server-related issue. which is given below:

Execute the following command into your terminal:

nano /etc/mysql/mysql.conf.d/mysqld.cnf
OR 
vi /etc/mysql/mysql.conf.d/mysqld.cnf

After that, add the following line to your MySQL.cnf file:

innodb_force_recovery = 2

Finally, execute the following command into your terminal to stop and start your mysql server:

sudo systemctl stop mysql.service   ---to shut it down
sudo systemctl start mysql.service  ---to try and start up and see the reason why it is not starting.