Home > Database > Mysql Tutorial > How to install MySQL on an ECon Amazon Linux 3 instance

How to install MySQL on an ECon Amazon Linux 3 instance

Linda Hamilton
Release: 2025-01-03 22:12:39
Original
533 people have browsed it

Are you working with an EC2 instance using Amazon Linux 2023 and need MySQL? Unlike previous versions, MySQL no longer comes preinstalled, and the installation process can be somewhat confusing. But don't worry! Here is a step-by-step guide to install it without complications and configure it properly.


1. Download MySQL RPM file

The first step is to download the file from the MySQL repository. This will allow you to access the most recent versions:

sudo wget https://dev.mysql.com/get/mysql80-community-release-el9-1.noarch.rpm  
Copy after login

2. Install the RPM file

This file will configure the repository needed for the installation:

sudo dnf install mysql80-community-release-el9-1.noarch.rpm -y  
Copy after login

3. Import the MySQL public key

To avoid problems with packet authentication, import the MySQL GPG key:

sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2023  
Copy after login

4. Install MySQL according to your needs

MySQL client only:

sudo dnf install mysql-community-client -y  
Copy after login

MySQL Server (includes client):

sudo dnf install mysql-community-server -y  
Copy after login

5. Configure MySQL server

Start the service and make sure it boots automatically with the system:

sudo systemctl start mysqld  
sudo systemctl enable mysqld  
Copy after login

Verify that the service is working:

sudo systemctl status mysqld  
Copy after login

? Here's an example of what the service status should look like:

Cómo instalar MySQL en una instancia ECon Amazon Linux 3


6. MySQL initial setup

Before using MySQL, you need to perform an initial configuration. First, find the temporary password generated during installation:

sudo grep 'temporary password' /var/log/mysqld.log  
Copy after login

? An example of the result is shown below:

Cómo instalar MySQL en una instancia ECon Amazon Linux 3

Next, run the initial configuration script:

sudo mysql_secure_installation  
Copy after login

Recommendations when setting the password

1. Meets security requirements:

  • At least one uppercase and one lowercase letter.
  • At least one number.
  • At least one special symbol (.!@#$%^&*()).

If you don't meet these criteria, you will see an error like this:

ERROR 1819 (HY000): Your password does not satisfy the current policy requirements.

Cómo instalar MySQL en una instancia ECon Amazon Linux 3

2. Evaluate the security level:

MySQL will show you a percentage that indicates how secure your password is. A level of 100% indicates maximum security.

Cómo instalar MySQL en una instancia ECon Amazon Linux 3

3. Adjust validation policy (optional):

If you prefer less strict passwords, you can modify the validation policy in the /etc/my.cnf file or through commands within MySQL.


What does the mysql_secure_installation script do?

This script guides you to make key adjustments to your security settings:

  • Change root password: Use a strong password following the recommendations above.
  • Disable anonymous users: This prevents unauthorized access.
  • Delete test database: Protect your system by deleting default data.
  • Restrict remote access: Ensures that it can only be accessed from the local machine.

Setup Wizard View

? Here are screenshots of what the wizard looks like while running:

Cómo instalar MySQL en una instancia ECon Amazon Linux 3

Cómo instalar MySQL en una instancia ECon Amazon Linux 3


Ready! ?

You now have MySQL fully installed and configured on your EC2 instance running Amazon Linux 2023.

Do you have any questions or want to share your experience? Leave it in the comments! ??

The above is the detailed content of How to install MySQL on an ECon Amazon Linux 3 instance. For more information, please follow other related articles on the PHP Chinese website!

source:dev.to
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template