For anyone who is not familiar with installing MySQL on Amazon Linux, you can use the following steps to install it:
- Download the MySQL Yum repository as follows:
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
- Install the Yum repository file using the following commands:
sudo yum localinstall mysql57-community-release-el7-8.noarch.rpm
This will add the MySQL Yum repository to our system's repository list and downloads the GnuPG key to check the integrity of the package we will download.
- Install the MySQL community server as follows:
sudo yum install mysql-community-server
- Start the MySQL server using this command:
sudo service mysqld start
- Get the generated root password from the log file as follows:
sudo grep 'temporary password' /var/log/mysqld.log
- Change the root password, as shown here:
mysql –u root –p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'k7Ayy$KTCcrM%2F3';
- Create a database as follows:
CREATE DATABASE task_agile CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
- Create a database user as follows:
CREATE USER 'app_user'@'%' IDENTIFIED BY '12$456!';
GRANT ALL PRIVILEGES ON task_agile . * TO 'app_user'@'%';
FLUSH PRIVILEGES;