news
Serverspace Technologies in the UAE: Launch of Falconcloud
WB
August 6, 2020
Updated July 19, 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:

Mysqlversion
Sreenshot 1.Download MySQL.

For example:

wget https://dev.mysql.com/get/mysql-apt-config_0.8.26-1_all.deb

Install the .deb:

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

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

For example:

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

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
Screenshot 7. 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
Contents of the configuration file
Screenshot 9. Contents of the configuration file.

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:

ufw allow $yoursqlport

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:
2 out of 5
Аverage rating : 2.3
Rated by: 27
1101 CT Amsterdam The Netherlands, Herikerbergweg 292
+31 20 262-58-98
700 300
ITGLOBAL.COM NL
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.