Installing MySQL 8 server & client on Amazon Linux 2023

MySQL Database server can easily be installed on Amazon Linux 2023 using the command. It is an open-source relational database management system available directly from most of the Linux distro’s official package repositories. Oracle developed this widely used database server, which is known for its performance, reliability, and ease of use, making it a great choice for both small—and large-scale projects.

Step 1: Update Al2023 Packages

It is essential to update the packages of your Amazon Linux 2023 before planning to install some packages. Running the system update command will install the latest available version of packages and refresh the DNF package manager repo cache. It also allows you to find the latest versions of packages available. Therefore, access your AWS Linux command terminal and run the given command.

sudo dnf update

Step 2: Download MySQL Yum repository

Like many other Linux systems, MySQL is not anymore available to install directly using the default system repository of Amazon Linux 2023 as well, instead, MariaDB is. Therefore, you can prefer MariaDB, however, if you specifically need the MYSQL then first we manually need to download its YUM repository from the Oracle website. To make things easy, here is the command to follow:


If you don’t have the wget tool then get it using – sudo dnf install wget

Add mysql yum repo amazon linux 2023

Step 3: Install MySQL 8 on Amazon Linux 2023

Once the MySQL Yum repository is successfully added to your Amazon Linxu 2023, we can install the latest available MySQL community server and client on our system.

First run:

sudo dnf update

After that, execute the installation command using the DNF package manager.

sudo dnf install mysql-community-server
Install MySQL Server on Amazon Linux 2023

Step 4: Start MySQL Service

After the installation, start the MySQL service and enable it to activate automatically upon system boot or crash.

sudo systemctl start mysqld
sudo systemctl enable mysqld

To check the service status:

sudo systemctl status mysqld
MySQL Service status

Step 5: Secure MySQL Installation

It is not necessary, initially, but if you are planning to use a Database server commercially where public users are going to access the data through it, then it’s recommended to secure your MySQL installation by setting a root password, removing anonymous users, disabling remote root login, and more.

However, first find the default password set by MySQL for the root user, using:

sudo grep 'temporary password' /var/log/mysqld.log

In the output, you will see the password; copy that.

After that, run the following command and follow the prompts:

sudo mysql_secure_installation -p
Secure MYSQL 8

Paste the temporary password you have copied and hit the Enter key.

Set a secure password. After that, the system will ask you to check the strength of the password to validate it. You can press Y or N as per your choice. Following that, pursue the wizard further to secure your MySQL Database server instance on Amazon Linux 2023.

Find default MYSQL 8 password

Step 6: Access Database CLI

To access the MySQL command-line interface, use the following command:

mysql -u root -p

You’ll be prompted to enter the root password you set during the secure installation step.

Step 7: Create a New MySQL User (Optional)

For security reasons, it’s recommended not to use the root user for everyday tasks. Instead, create a separate user with appropriate privileges. While in the MySQL command-line interface, run the following commands to create a new user and grant them privileges:

CREATE USER 'yourusername'@'localhost' IDENTIFIED BY 'yourpassword';
GRANT ALL PRIVILEGES ON *.* TO 'yourusername'@'localhost' WITH GRANT OPTION;

Whereas, in the future, if you want to change the root user name again, you can use the command:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'newpassword!';

Replace ‘yourusername‘ with your desired username and ‘yourpassword‘ with your chosen password.


So, this was the way to quickly install MySQL on Amazon Linux 2023 if you start working with this updated version of AWS Linux. Whether you’re building web applications, data-driven systems, or any software requiring a reliable database, MySQL offers a robust solution with a proven track record.

1 thought on “Installing MySQL 8 server & client on Amazon Linux 2023”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.