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.
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
This file will configure the repository needed for the installation:
sudo dnf install mysql80-community-release-el9-1.noarch.rpm -y
To avoid problems with packet authentication, import the MySQL GPG key:
sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2023
sudo dnf install mysql-community-client -y
sudo dnf install mysql-community-server -y
Start the service and make sure it boots automatically with the system:
sudo systemctl start mysqld sudo systemctl enable mysqld
Verify that the service is working:
sudo systemctl status mysqld
? Here's an example of what the service status should look like:
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
? An example of the result is shown below:
Next, run the initial configuration script:
sudo mysql_secure_installation
1. Meets security requirements:
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.
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.
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.
This script guides you to make key adjustments to your security settings:
? Here are screenshots of what the wizard looks like while running:
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!