MySQL server package installation:
Install package:
wget https://dev.mysql.com/get/mysql-apt-config_0.8.28-1_all.deb
dpkg -i mysql-apt-config_0.8.28-1_all.deb
*During the installation, you will be prompted to choose the version of MySQL to install. Select the desired version and choose “OK” to continue.
Install MySQL:
apt update
apt install mysql-server mysql-client -y
Secure MySQL:
First set new password for root from mysql:
mysql
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password-here';
exit
Run the secure script:
mysql_secure_installation
Select options:
- Set root password? [Y/n] y
- Remove anonymous users? [Y/n] y
- Disallow root login remotely? [Y/n] y
- Remove test database and access to it? [Y/n] y
- Reload privilege tables now? [Y/n] y
*When promoted for the root password, enter whatever you set when you ran the above SQL query.