Skip to content

Instantly share code, notes, and snippets.

@waiphyo285
Created October 20, 2024 08:15
Show Gist options
  • Save waiphyo285/ca707bba258920a9faab53dd3c1a05a3 to your computer and use it in GitHub Desktop.
Save waiphyo285/ca707bba258920a9faab53dd3c1a05a3 to your computer and use it in GitHub Desktop.

MySQL 8.0 Installation on Ubuntu 24.04

Step 1. Update Package Index

sudo apt update

Step 2. Install MySQL 8.0

sudo apt install mysql-server-8.0

Step 3. Manage MySQL Service

  • Check status: sudo systemctl status mysql.service
  • Start service: sudo systemctl start mysql.service
  • Enable service: sudo systemctl enable mysql.service

Step 4. Find MySQL Configuration

sudo find / -type f -name "mysqld.cnf"

Step 5. Edit Configuration

sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf

# Add or modify:
[mysqld]
default_authentication_plugin=caching_sha2_password

Step 6. Secure MySQL Installation

sudo mysql_secure_installation

Step 7. Restart MySQL

sudo systemctl restart mysql.service

Step 8. Create Users

CREATE USER 'primary_user'@'localhost' IDENTIFIED BY 'YourPassword123!';
CREATE USER 'secondary_user'@'localhost' IDENTIFIED BY 'YourPassword321!';

Step 9. Grant Privileges

# All privileges:
GRANT ALL PRIVILEGES ON *.* TO 'primary_user'@'localhost';

# Specific privileges:
GRANT INSERT, SELECT, UPDATE, DELETE ON *.* TO 'secondary_user'@'localhost';

Step 10. Apply Changes

FLUSH PRIVILEGES;

Step 11. Exit MySQL

exit

Note:

This content is summarized based on instructions from the article: How to Install MySQL on Ubuntu 24.04

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment