How to Install MySQL 5.7 on Debian 9
Debian 9 is the latest stable release in the Debian operating system line, which is an open source project based on Unix systems. The current release, given the codename Stretch, has several changes that impact user functionality and third-party application compatibility. Each major Debian release provides new packages, software updates, and comes with three years of support for the release; stable releases, such as Stretch, are released every two years.
However, one major change from the previous Debian 8 release is the change from MySQL to MariaDB. With the new release, the previous instances of MySQL are being replaced by the equivalent instance of MariaDB. This guide will help you install MySQL 5.7 on a node running the Debian Stretch operating system.
To get started with installing the MySQL packages on Stretch, you need to have a cloud server or dedicated server node, whichever you prefer, with an current instance of Debian Stretch installed.
Mentioned earlier, one of the biggest changes from the previous stable release to this release was the replacement of MySQL with MariaDB; MySQL was the default. However, it’s possible to install MySQL as the default database, replacing MariaDB, with an official MySQL repository.
During this process, having root user access, sometimes called privileged access, may be necessary to complete the setup. You will be prompted to create a MySQL root password during installation as well.
Installing MySQL 5.7 on Debian 9
The first step in installing the official MySQL instance is to go to MySQL’s website, find the correct .deb package, and download the .deb package.
Now that the .deb package is downloaded, you will need to download it to your Debian server, following the below example:
Once downloaded to your server, check the .deb package name, then install it with dpkg:
Follow the steps to complete the download of your .deb package:
dpkg -i mysql-apt-config_0.8.8-1_all.deb
During the installation, you will be prompted to select options for your install. Make sure to leave the default options in place, then click “OK”
After the installation is complete, now you can update the package list:
When the above steps have completed, you are now ready to proceed with installing MySQL, both the server and the client. You will also receive a prompt, during setup, to create a MySQL root user password:
apt install mysql-server mysql-client
Once the installation of the MySQL server and MySQL client have completed, you need to enable the MySQL instance on your server, then start MySQL:
systemctl enable mysql && systemctl start mysql
Securing your MySQL installation is essential, so run the below script, leaving the default settings alone, to secure your MySQL server and client:
Congratulations! You’ve completed an install of MySQL 5.7 on your Debian 9 cloud server or dedicated server node. While installing this official MySQL instance, you’ve replaced the existing MariaDB instance; this makes MySQL the default database software. If you had success using this guide to update your current Debian release with the MySQL instance, please share it with others going through the same process.