Are you trying to install MySQL on Debian?
This guide is for you.
MySQL is a well-known and open-source relational database management system that is pre-installed on Linux Debian's repository. MariaDB is available as the default database in Debian 10.
Therefore, you need to install the MySQL server with all its dependencies on your Debian 10 system.
Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform Software Installation tasks on their Servers.
In this context, we shall look into how to install the MySQL server on Debian 10.
Steps to install MySQL on Debian ?
To install MySQL, you need to log into your Server as the root user with sudo privilege. You can either use your Terminal or an SSH tool such as Putty.
Then follow the steps given below to install the MySQL server on your Debian 10 system:
1. Open a terminal
i. Click on the 'Activities' and then enter the terminal in the application search bar.
ii. Click on the terminal icon which will be displayed under the search bar.
2. Add or Configure MySQL Repository in Debian 10
For the installation of MySQL, you need to first add the MySQL apt repository to your Debian 10 system.
i. For this purpose, go to the download page of the repository and grab the latest release of the MySQL package by using the below-mentioned wget command:
$ wget http://repo.mysql.com/mysql-apt-config_0.8.13-1_all.deb
ii. Once the download of the latest release package is completed, install it by executing the following command with sudo privileges:
$ sudo apt install ./mysql-apt-config_0.8.13-1_all.deb
During the installation, the configuration menu will be displayed on the system where you can select the MySQL version that you want to install.
Here, MySQL 8.0 is already selected. You can select other versions according to your server requirements. Now, select 'OK' by pressing the 'Tab' key and hit 'Enter'.
3. Update apt package list
The recommended method is to update the repository packages list before installing any new application on your system.
Therefore, update apt packages by using the following command:
$ sudo apt update
4. Install MySQL
i. After updating the Debian apt repository, you will execute the below-given command to install the MySQL server packages on Debian 10:
$ sudo apt install mysql-server
ii. Here, you will be asked to enter the MySQL root user password. Leave it blank that will set further in this guide.
iii. In the next dialog, a message will display on the system in order to inform you about the MySQL 8.0 authentication.
iv. Ensure that this authentication plugin is supported by your MySQL application, and then select the MySQL 8 authentication plugin.
5. Check Status of MySQL Service
Once the installation process is completed, MySQL services will automatically start on your system.
You can check service running status by typing the following command:
$ sudo systemctl status mysql
6. Make secure installation of MySQL
By executing the following command you can make the installation of the MySQL server more secure.
i. Here, you need to set the root account password as follows:
$ sudo mysql_secure_installation
In the next step, you will be prompted to configure the 'VALIDATE PASSWORD PLUGIN'. This plugin is usually used to test the MySQL user's password strength.
It consists of three levels for password validation: low, medium, and strong. If you don't want to configure this plugin the hit 'Enter'.
ii. Next, you will set the root user MySQL account password.
iii. Once you have been entered the root account password, the script will ask you to answer the following questions:
Are you want to remove the anonymous user?
Are you want to restrict the of root user access to the local machine?
Want to remove the test database?
You should be response (yes) press 'y' to all questions in order to successfully complete the secure configuration.
7. Connect to the MySQL Server
To work on the MySQL database, a necessary package MySQL client is required that is pre-installed as a dependency of the MySQL server package during the installation process.
i. During the installation, if you have selected and installed the default authentication method for root login type then, run the following command:
$ sudo mysql
ii. For legacy authentication method, type the following command on the terminal:
$ mysql -u root -p
iii. You will be asked to enter the root account password which you have set in the above step mysql_secure_installation.
Once you have entered the password, MySQL shell environment will display on the terminal.