Home How to install MySQL server on Debian 9
Post
Cancel

How to install MySQL server on Debian 9

In this article we will show you how to install Oracle’s mysql server to your site instad of MariaDB mysql server. Prerequisites:

  • Debian 9
  • a sudo non-root user In the latest stable version of Debian, if you ask to install mysql-server, you now get installed mariadb automatically, with no (evident) way of installing Oracle’s MySQL.

Install Oracle’s APT Repositories:

1
echo -e "deb http://repo.mysql.com/apt/debian/ stretch mysql-5.7\ndeb-src http://repo.mysql.com/apt/debian/ stretch mysql-5.7" | sudo tee /etc/apt/sources.list.d/mysql.list

Before starting to use the repo, you have to add the repo public key as trusted:

1
2
sudo wget -O /tmp/RPM-GPG-KEY-mysql https://repo.mysql.com/RPM-GPG-KEY-mysql
sudo apt-key add /tmp/RPM-GPG-KEY-mysql

If you run apt-key listyou will see a new trusted key for apt:

1
2
3
4
5
6
7
8
9
10
11
12
13

/etc/apt/trusted.gpg
--------------------
...

pub dsa1024 2003-02-03 [SCA] [expires: 2019-02-17]
A4A9 4068 76FC BD3C 4567 70C8 8C71 8D3B 5072 E1F5
uid [ unknown] MySQL Release Engineering <mysql-build@oss.oracle.com>

...


Refresh your available package list

1
sudo apt update

Install myqsl-server:

1
sudo apt install mysql-server

To secure the installation, we can run a simple security script that will ask whether we want to modify some insecure defaults

1
mysql_secure_installation

You will be asked to enter the password you set for the MySQL root account. Next, you will be asked if you want to configure the VALIDATE PASSWORD PLUGIN.

Answer No for disable plugin.

Start and enable (to run after restart) your server:

1
2
sudo systemctl start mysql
sudo systemctl enable mysql