Installing MySQL:
sudo apt update
sudo apt install mysql-server
sudo systemctl start mysql.service
Configuring MySQL:
sudo mysql_secure_installation
Creating a Dedicated MySQL User and Granting Privileges:
sudo mysql
mysql -u root -p
CREATE USER 'mailapp'@'localhost' IDENTIFIED WITH authentication_plugin BY 'password';
CREATE USER 'mailapp'@'localhost' IDENTIFIED BY 'password';
CREATE USER 'mailapp'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
ALTER USER 'mailapp'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT on *.* TO 'mailapp'@'localhost' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'mailapp'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit
mysql -u mailapp -p