--- tags: 筆記, AWS, Amazon Linux 2, mysql, client --- # Install MySQL 5.7 client on Amazon Linux 2 ```bash= sudo yum install -y https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm sudo yum install -y mysql-community-client ``` As of 2022, you are required to import the latest GPG key using: `sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022` # Install MySQL 8.0 client on Amazon Linux 2 ```bash= sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022 sudo yum install -y https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm sudo yum install -y mysql-community-client ``` # Install MySQL 5.7 Server on Amazon Linux 2 ``` sudo yum update -y ``` The Amazon Linux default repositories contain MariaDB packages for the installation. To install the MySQL community release, first, configure MySQL yum repository on your machine. ``` sudo rpm -Uvh https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm ``` ``` sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022 ``` After that run the following command to install the MySQL 5.7 packages on your systems. This will also install all other required dependencies. ``` sudo yum install mysql-community-server ``` Once the MySQL installation is completed on your Amazon Linux system. You need to enable the MySQL service to start on system boot. Also, start the service using the following commands: ``` sudo systemctl enable mysqld sudo systemctl start mysqld ``` Once you start the MySQL server for the first time, an auto-generated password is set for the root account. You can find this password in MySQL logs. ``` sudo grep 'temporary password' /var/log/mysqld.log 2022-08-18T07:31:38.099501Z 1 [Note] A temporary password is generated for root@localhost: ?iY.1GmJba=J ``` Copy this password and use this for the post-installation setup wizard. The MySQL community server has been installed on your system. Now run the following command to apply security on the MySQL server. Simply execute the below command and follow the security wizard. ``` sudo mysql_secure_installation ``` Enter the root password found in the above step, then set a new password for the MySQL root account. Next, follow the onscreen instructions and Press Y for all other operations to apply improved security.