MySQL is a well known relational database system developed by Oracle. It is used to store, manage and retrieve the data. When it comes to performance, MySQL is fast, reliable and easy to manage. MySQL today is used by most of the mobile applications, websites, and Enterprise level softwares. MySQL can be used with various setups as it supports various storage engines which makes it most suitable for scalable setups. Another best thing about MySQL is that it is ACID complaint which ensures that the database transactions are highly reliable.
Let’s see how to install MySQL on Ubuntu 24.
In this Tutorial, you will learn
- Prerequisites
- Step 1 – Update the system
- Step 2 – Install MySQL on Ubuntu 24.04
- Step 3 – Create Database
- Conclusion
Prerequisites
- An Ubuntu 24 server
- A sudo user with administrative privileges
Step 1 – Update the system
Let’s first update the system by executing a couple of commands.
# sudo apt update
# sudo apt upgrade -y
Step 2 – Install MySQL on Ubuntu 24.04
Now let’s install MySQL on Ubuntu using the command given below
# sudo apt install mysql-server -y
Set up MySQL and use the options as shown below
# sudo mysql_secure_installation
Enter current password for root (leave blank if none): {Just hit Enter key here}
Switch to unix_socket authentication? (Y/n):N {Press N and hit Enter}
Change the root password? (Y/n):Y {Press Y and hit Enter to setup root password}
Remove anonymous users? (Y/n):Y {Press Y and hit Enter}
Disallow root login remotely? (Y/n):Y {Press Y and hit Enter}
Remove test database and access to it? (Y/n): Y {Press Y and hit Enter}
Reload privilege tables now? (Y/n): Y {Press Y and hit Enter}
Execute the given below command to check the installation
# sudo mysql --version
Output
mysql Ver 8.4.5 for Linux on x86_64 (MySQL Community Server - GPL)
Now lets start and enable the MySQL server
# sudo systemctl start mysql
# sudo systemctl enable mysql
Step 3 – Create Database
Final step is to create a database and set it up
# sudo mysql -u root -p
Enter password that you have created in step 2
Create a database
mysql> CREATE DATABASE your_database_name;
Create a user
mysql> CREATE USER 'user_name'@localhost IDENTIFIED BY 'strong_password';
Grant privileges to user for the database
GRANT ALL PRIVILEGES ON your_database_name.* TO 'user_name'@'localhost';
Lets refresh the privileges and exit MySQL
FLUSH PRIVILEGES;
EXIT;
Conclusion
With this we have successfully installed MySQL on Ubuntu 24.
Leave a Reply