Install an RPM repository package by running the commands below:
sudo yum install https://dev.mysql.com/get/mysql80-community-release-el7-5.noarch.rpm
A new repository file has been created inside the /etc/yum.repos.d directory.
$ ls /etc/yum.repos.d
amzn2-core.repo amzn2-extras.repo mysql-community.repo mysql-community-source.repo
You can also view list of configured repositories with yum command.
$ sudo yum repolist
Once the repository has been added, install MySQL 8 server packages on Amazon Linux 2.
sudo amazon-linux-extras install epel -y
sudo yum -y install mysql-community-server
The next step is to start MySQL server services.
sudo systemctl enable –now mysqld
A superuser account ‘root’@’localhost is created with initial password set and stored in the error log file. To reveal it, use the following command:
use the following command:
$ sudo grep ‘temporary password’ /var/log/mysqld.log
Use this initial password to harden the server.
$ sudo mysql_secure_installation -p
Enter password: <INPUT-PRINTED-PASSWORD>
Set new password and set other settings to better secure access to MySQL server.
Securing the MySQL server deployment.
The existing password for the user account root has expired. Please set a new password.
New password: <SET-NEW-PASSWORD>
Re-enter new password: <CONFIRM-NEW-PASSWORD>
The ‘validate_password’ component is installed on the server.
The subsequent steps will run with the existing configuration
of the component.
Using existing password for root.
Estimated strength of the password: 100
Change the password for root ? ((Press y|Y for Yes, any other key for No) :
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Normally, root should only be allowed to connect from
‘localhost’. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
By default, MySQL comes with a database named ‘test’ that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
– Dropping test database…
– Removing privileges on test database…
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
You can update root password anytime from MySQL shell.
$ mysql -uroot -p
mysql> ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘MyNewStrongP@ssw0d!’;
The Password Policy is requires:
- At least one uppercase letter
- At least one lowercase letter
- At least one digit
- At least one special character
- Total password length is at least 8 characters.
You have installed MySQL 8 server successfully on Amazon Linux 2 and ready to roll..
Below are other guides on Amazon Linux available in our website.