🗄️ How To Install MySQL on Ubuntu 20.04
MySQL is an open-source relational database management system. This tutorial covers installing MySQL 8.0, securing it, and creating dedicated database users.
1Install MySQL
Update packages and install MySQL server:
sudo apt update
sudo apt install mysql-server
Check MySQL is running:
sudo systemctl status mysql
2Secure MySQL Installation
Run the security script:
sudo mysql_secure_installation
⚠️ This script configures password policies, removes anonymous users, and disables remote root login.
3Access MySQL
sudo mysql
4Create a Dedicated User
CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
Grant privileges:
GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit
5Test the New User
mysql -u username -p
🎉 MySQL is now installed and secured on your Ubuntu server!