sudo apt update
sudo apt install mysql-server-8.0
- Check status: sudo systemctl status mysql.service
- Start service: sudo systemctl start mysql.service
- Enable service: sudo systemctl enable mysql.service
sudo find / -type f -name "mysqld.cnf"
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
# Add or modify:
[mysqld]
default_authentication_plugin=caching_sha2_password
sudo mysql_secure_installation
sudo systemctl restart mysql.service
CREATE USER 'primary_user'@'localhost' IDENTIFIED BY 'YourPassword123!';
CREATE USER 'secondary_user'@'localhost' IDENTIFIED BY 'YourPassword321!';
# All privileges:
GRANT ALL PRIVILEGES ON *.* TO 'primary_user'@'localhost';
# Specific privileges:
GRANT INSERT, SELECT, UPDATE, DELETE ON *.* TO 'secondary_user'@'localhost';
FLUSH PRIVILEGES;
exit
Note:
This content is summarized based on instructions from the article: How to Install MySQL on Ubuntu 24.04