This guide will demonstrate how to install MySQL 8 on Debian 9.
Install MySQL 8 on Debian 9
To install MySQL 8 on Debian 9, we are going to use MySQL APT repository which provides deb
packages for installing and managing the MySQL server, client, and other components.
Run System Update
Update your system packages.
apt update
apt upgrade
Add MySQL APT Repository
MySQL APT repository is not available on the default Debian 9 system software repository list. Therefore, download the repo and install it as shown below;
wget https://repo.mysql.com//mysql-apt-config_0.8.13-1_all.deb
apt install ./mysql-apt-config_0.8.13-1_all.deb
During the installation, you will be prompted to select MySQL product version to install. Leave the defaults and select Ok and press Enter to install the repo.
Once the installation is done, you need to run system update to load package list.
apt update
Install MySQL 8 on Debian 9
Now that you got MySQL APT repos in place, you can now install MySQL 8 by running the installation commands below;
apt install mysql-server
During the installation, you will be prompted to set MySQL root password. Hence, set the password and re-enter it when prompted.
Next, set the authentication plugin. Select the recommended option and proceed.
Want to install MySQL 8 on FreeBSD 12? See the link below;
Running MySQL 8
MySQL 8 should be running immediately after the installation. Check status by executing the command below;
systemctl status mysql.service
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2019-06-21 07:58:25 EDT; 2min 30s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 2822 ExecStartPre=/usr/share/mysql-8.0/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 2857 (mysqld)
Status: "SERVER_OPERATING"
Tasks: 37 (limit: 4915)
CGroup: /system.slice/mysql.service
└─2857 /usr/sbin/mysqld
Jun 21 07:58:24 debian9 systemd[1]: Starting MySQL Community Server...
Jun 21 07:58:25 debian9 systemd[1]: Started MySQL Community Server.
It is also set to run on system boot by default.
systemctl is-enabled mysql.service
enabled
MySQL 8 initial Security
MySQL comes bundled with a security script called mysql_secure_installation that is used to improve MySQL installation security. The script can run with no options as shown below.
mysql_secure_installation
Securing the MySQL server deployment.
Enter password for user root: ENTER THE PASSWORD SET DURING THE INSTALLATION
Next, you are prompted whether to enable the validate password plugin that is used to enforce password complexity. Type Y and press Enter to enable or any other key to ignore.
VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?
Press y|Y for Yes, any other key for No: Y
If you accept to enable the validate password plugin, you will be prompted to choose the level of complexity, with three levels provided. Choose the level and press ENTER to proceed.
There are three levels of password validation policy:
LOW Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 1
Next, you are prompted whether to reset or use existing root password.
Using existing password for root.
Estimated strength of the password: 100
Change the password for root ? ((Press y|Y for Yes, any other key for No) : ENTER to retain existing password
Once the next prompts, press Y and enter to remove anonymous users, disallow remote root login, remove test databases and reload privileges tables to apply the changes.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
- Dropping test database...
Success.
- Removing privileges on test database...
Success.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.
All done!
MySQL 8 is now installed and running on Debian 9. You can check the version of MySQL as a way of verifying the installation. You can simply use mysqladmin to check the version instead of logging in running the select version query.
mysqladmin -u root -p version
Enter password:
mysqladmin Ver 8.0.16 for Linux on x86_64 (MySQL Community Server - GPL)
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Server version 8.0.16
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /var/run/mysqld/mysqld.sock
Uptime: 21 min 42 sec
Threads: 2 Questions: 13 Slow queries: 0 Opens: 144 Flush tables: 3 Open tables: 48 Queries per second avg: 0.009
Well done. You have MySQL 8.0.16 running on your debian 9 server.
You can as well check our other related guides by following the links below;
Install MySQL 8 on Fedora 30/Fedora 29
Install LAMP Stack on Fedora 30
How To Install LAMP (Linux, Apache, MySQL, PHP) Stack on Fedora 28/29
Install MariaDB 10.3 on CentOS 7