Installing MySQL in Debian 10

MySQL is the most widely used database management system (DBMS) open source. It is used to store and retrieve data in many applications. In 10 out of the box Debian installed DBMS MariaDB as alternative to MySQL, and in most cases it works well.

But if you want to obtain a DBMS with the features inherent only to MySQL, you will need to install it from the official repository MySQL. Next, we discuss how to install MySQL Debian 10 from the developers.

How to install MySQL in Debian 8 10

Step 1: Adding repository for MySQL

To install MySQL in Debian, you need to download and install the APT repository is contained in .deb package that manages configuration and software installation MySQL.

cd /tmp


sudo dpkg-i mysql-apt-config_0.8.13-1_all.deb

During package installation you will be prompted to configure the MySQL APT repository for versions of MySQL server and other components you want to install. To install the latest version of leave it as is, go to OK and press Enter.

Step 2: Install MySQL

After adding the repository, update apt package cache and install the MySQL server. This will also install the packages for the client and other dependencies.

sudo apt update

sudo apt install mysql-server

During the installation a dialog box will appear a configuration in which you want to set the root password for MySQL. Enter safe and strong password, and then confirm it.

After that will warn you about a new authentication system based on SHA256, which is used in MySQL, click Ok. Select the authentication plugin (leave the default option to use the recommended plugin) and click Enterto complete the installation process.

When the package installation is complete, the installer will start the MySQL service and set it startup. To make sure that the MySQL service is running, check its status using the following commands.

sudo systemctl status mysql

There are a few systemctl commands that you need to know in order to manage (start, stop or restart) your MySQL service when it is needed:

sudo systemctl start mysql

sudo systemctl restart mysql

sudo systemctl stop mysql

sudo systemctl reload mysql

Step 3: configure security for MySQL

The MySQL server out of the box is not protected, and to enhance security, you will need to run the script mysql_secure_installation. Run:

sudo mysql_secure_installation

Read the description of each question and correctly respond to them. First, enter the root password that you specified during package installation. You can choose y (for Yes) or n (for No) to use or not to use the VALIDATE PASSWORD.

When the script prompts you to set a new password for the root user, click No (you already have it installed during the installation of the package). Then carefully follow the other prompts and select y (for YES) to remove anonymous users, disallow remote root logins to the system, remove test database and reload privileges table.

Configure MySQL Debian is complete, you can go on to use.

Step 4: Check For MySQL

After you have completed security setup of MySQL, you can start using it to store data for your web sites or web applications. To access the MySQL shell, run the following command (root user password, enter the query as shown in the screenshot):

mysql-u root-p


In this article we tell how to install MySQL Debian 10. If you have any questions on this article, please ask in the comments!


(Visited 22 times, 1 visits today)