Serverspace Black Friday
WB
September 3, 2020
Updated June 7, 2023

How to Install MySQL on Debian 10

Databases Debian

In this article, you will learn how to install the MySQL Server on Debian 10.x. It also works on another Linux-based distribution (like Ubuntu).

In the Serverspace you can create a server with already installed app "MySQL".

How to install MySQL on Debian 10:

Step 1. Add the MySQL Repository

At first, let's update the packages:

apt update
apt install gnupg

Next, download MySQL from the offical page or use wget command:

wget https://dev.mysql.com/get/mysql-apt-config_x.x.x-x_all.deb

where x.x.x-x is the MySQL version (for example, 0.8.15-1):

Download MySQL
Screenshot 1. Download MySQL.

Install the .deb:

sudo dpkg -i mysql-apt-config_x.x.x-x_all.deb

where x.x.x-x is the MySQL version.

When you attempt to install the package, it will ask you what product and version you want to install. Here you can select The MySQL version, Tools, Connectors (like MySQL Workbench), and preview packages. To select the version, hit the first option:

Choose MySQL Server & Cluster
Screenshot 2. Choose MySQL Server & Cluster.

Select the version you will use. Once selected, it will bring you to the previous menu — press Ok button:

Select the version you will use
Screenshot 3. Select the version you will use.

Update the apt repository:

apt-get update

The package for installing the server is «mysql-community-server» and its version is the same you have selected before in the package installer.

Step 2. Install the MySQL Server

Install the MySQL Server using the command:

sudo apt-get install mysql-community-server
Installation process
Screenshot 4. Installation process.

When apt finishes downloading, the installer will ask for a root password:

Enter the root password
Screenshot 5. Enter the root password.

You have two options:

  • Leave the password blank: the server will use unix sockets authentication. It means you can only access the server as a root user or as a user with sudo;
  • Set a password: the authentication method will be the same for other users.

If you set a password, the installer will ask which authentication plugin to use, strongly encrypted password (MySQL 8.x), or legacy method (MySQL 7.x and earlier). To select options use arrows or the Tab button. You must select a method that is compatible with your client/program. WOnce you have selected all options, the installation process will be finished and the service will start automatically:

Select the default authentication plugin
Screenshot 6. Select the default authentication plugin.

Now, check the service status with systemctl:

systemctl status mysql.service
Checking service status
Screenshot 7. Checking service status.

If you see "active", it means that the server is running without errors. Press Q or Ctrl + C to exit.

Next, run the command as a root user to safely configure the SQL service:

mysql_secure_installation

The program will ask you questions. You will need to answer Yes (Y/y button) or No (any other key):

Running mysql_secure_installation
Screenshot 8. Running mysql_secure_installation.

If you want to allow remote access, edit the file «mysqld.conf» in etc/:

sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf

At the end of the file, add the option "bind_address" with the value of localhost:

bind-address=127.0.0.1

Save the file and restart the service with systemctl:

systemctl restart mysql

Note: remember to open the MySQL port (it will be good to specify the standard MySQL port). If you use ufw:

where instead of yoursqlport write your MySQL port.

If you use iptables:

iptables –A INPUT –p tcp –dport $yoursqlport –j ACCEPT

where instead of yoursqlport write your MySQL port.

 

Vote:
5 out of 5
Аverage rating : 5
Rated by: 1
33145 North Miami, FL 2520 Coral Way apt 2-135
+1 302 425-97-76
700 300
ITGLOBAL.COM CORP
700 300
We use cookies to make your experience on the Serverspace better. By continuing to browse our website, you agree to our
Use of Cookies and Privacy Policy.