How to Start and Stop MySQL Server in Ubuntu?

28-Mar-2023

.

Admin

How to Start and Stop MySQL Server in Ubuntu?

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.

I hope it can help you...

#Ubuntu