MySQL is a free database system recognized for storing and organizing data on the web. It is easy and user-friendly to handle numerous tasks. With its convenient and extensive features, MySQL is the first choice for developers.
The main purpose of this technical writing is to elaborate on the installation of MySQL on the Debian 12.5 system.
How to Install MySQL on Debian 12.5?
Follow these single-line commands from the terminal to install the MySQL package on Debian 12.5.
Step 1: Update Debian Repository List
First, install the latest updates for the Debian package list using the command:
sudo apt update

This command is useful before installing a new package on your Debian system.
Step 2: Install MySQL
Utilize the APT package manager for easy installation of the MySQL package. Here is the command:
sudo apt install mysql-server -y

Respond to prompt questions according to your needs. For example:
Enter a strong password for the root:



You can choose either of the options; however, the first option is strongly recommended:


Once the configuration process has ended, a completion message will appear on the terminal screen.
Step 3: Confirm Release Version
Execute the below command to check the MySQL release version installed on your system:
mysql -V

Currently, MySQL 8.0.37 has been successfully installed on your Debian 12.5 machine.
Step 4: Check MySQL Status
To verify that MySQL is running and active, execute the following command:
systemctl status mysql

Ensure that MySQL is installed and active, as indicated in the above terminal output.
Step 5: Secure MySQL Installation
After installing MySQL, it is important to secure the installation by executing the following command. During you can choose the security options that best suit your requirements:
sudo mysql_secure_installation



When you see “All done” on your terminal screen, it indicates that your MySQL installation is now secure from unauthorized users.
How to Completely Remove MySQL from Debian 12.5?
Here are some useful command(s) to remove the MySQL package from Debian 12.5.
Step 1: Completely Remove MySQL
To remove the MySQL package completely, combine the purge and autoremove commands followed by the package name (mysql-server):
sudo apt purge --autoremove mysql-server

You will be prompted with questions about removing directories. Respond to them accordingly:


Finally, a message confirming the removal and purging of the MySQL package will appear on your terminal screen.
FAQs
Why should I install MySQL on my Debian 12.5?
MySQL is the preferred choice among developers because it is user-friendly and capable of handling numerous tasks easily.
How can I install MySQL on my Debian 12.5?
With the help of a one-liner code, you can install the MySQL package on your Debian system. The command is; “sudo apt install mysql-server -y”. You can check the active status via the command “systemctl status mysql”.
Conclusion
On Debian 12.5, install the MySQL package through simple and easy commands. After installing the necessary updates, utilize “sudo apt install mysql-server -y” to set up the MySQL on your system. You can also secure the MySQL installation via the command “sudo mysql_secure_installation”.
Hence, you have successfully installed MySQL on your Debian 12.5 system. Moreover, you also learned the removal of the package using a simple command.