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 install gnupg
Next, download MySQL from the offical page or use wget command:
where x.x.x-x is the MySQL version (for example, 0.8.15-1):
Install the .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:
Select the version you will use. Once selected, it will bring you to the previous menu — press Ok button:
Update the apt repository:
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:
When apt finishes downloading, the installer will ask for a 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:
Now, check the service status with systemctl:
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:
The program will ask you questions. You will need to answer Yes (Y/y button) or No (any other key):
If you want to allow remote access, edit the file «mysqld.conf» in etc/:
At the end of the file, add the option "bind_address" with the value of localhost:
Save the file and restart the service with systemctl:
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:
where instead of yoursqlport write your MySQL port.