SQL stands for “structured query language” and it makes up the name MySQL, which is the combination of My and SQL. My is the name of MySQL’s co-founder, Monty Widenius daughter. MySQL is an open source database management system created primarily for the management of relational databases. For commercial use cases you can buy a license from Oracle for premium support.
In this article I’ll walk you through the installation of MySQL 8.0 on Amazon Linux 2 Server running on AWS Cloud or as a Virtual Machine somewhere in your data center. If you need a detailed article on the new features of MySQL 8, checkout the official release notes page.
Install MySQL 8 on Amazon Linux 2
Amazon Linux is a derivative of CentOS 7 Linux server with few extra repositories and packages for improved performance and integrations with other AWS cloud services. You can check the release of your server by running the following command in the terminal.
$ cat /etc/os-release NAME="Amazon Linux" VERSION="2" ID="amzn" ID_LIKE="centos rhel fedora" VERSION_ID="2" PRETTY_NAME="Amazon Linux 2" ANSI_COLOR="0;33" CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2" HOME_URL="https://amazonlinux.com/"
Step 1: Add MySQL Yum Repository to Amazon Linux 2
First, we need to add the MySQL Yum repository to our Amazon Linux 2 server’s repository list. This operation is only done once and provides all MySQL package versions repositories.
Install an RPM repository package by running the commands below:
sudo yum install https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
Hit the y key in your keyboard when prompted to start the installation.
Loaded plugins: dkms-build-requires, langpacks, priorities, update-motd mysql80-community-release-el7-3.noarch.rpm | 25 kB 00:00:00 Examining /var/tmp/yum-root-8dO5e8/mysql80-community-release-el7-3.noarch.rpm: mysql80-community-release-el7-3.noarch Marking /var/tmp/yum-root-8dO5e8/mysql80-community-release-el7-3.noarch.rpm to be installed Resolving Dependencies --> Running transaction check ---> Package mysql80-community-release.noarch 0:el7-3 will be installed --> Finished Dependency Resolution amzn2-core/2/x86_64 | 3.7 kB 00:00:00 Dependencies Resolved ================================================================================================================================================================== Package Arch Version Repository Size ================================================================================================================================================================== Installing: mysql80-community-release noarch el7-3 /mysql80-community-release-el7-3.noarch 31 k Transaction Summary ================================================================================================================================================================== Install 1 Package Total size: 31 k Installed size: 31 k Is this ok [y/d/N]: y
Verify that the package was installed successfully.
Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : mysql80-community-release-el7-3.noarch 1/1 Verifying : mysql80-community-release-el7-3.noarch 1/1 Installed: mysql80-community-release.noarch 0:el7-3 Complete!
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 Loaded plugins: dkms-build-requires, langpacks, priorities, update-motd 35 packages excluded due to repository priority protections repo id repo name status amzn2-core/2/x86_64 Amazon Linux 2 core repository 20,877 amzn2extra-docker/2/x86_64 Amazon Extras repo for docker 28 mysql-connectors-community/x86_64 MySQL Connectors Community 130+35 mysql-tools-community/x86_64 MySQL Tools Community 115 mysql80-community/x86_64 MySQL 8.0 Community Server 193 repolist: 21,343
Step 2: Install MySQL 8 on Amazon Linux 2
Once the repository has been added, install MySQL 8 server packages on Amazon Linux 2.
sudo amazon-linux-extras install epel -y sudo yum install mysql-community-server
A number of dependencies are installed in the process.
Dependencies Resolved ================================================================================================================================================================== Package Arch Version Repository Size ================================================================================================================================================================== Installing: mysql-community-libs x86_64 8.0.21-1.el7 mysql80-community 4.5 M replacing mariadb-libs.x86_64 1:5.5.64-1.amzn2 mysql-community-libs-compat x86_64 8.0.21-1.el7 mysql80-community 1.2 M replacing mariadb-libs.x86_64 1:5.5.64-1.amzn2 mysql-community-server x86_64 8.0.21-1.el7 mysql80-community 499 M Installing for dependencies: mysql-community-client x86_64 8.0.21-1.el7 mysql80-community 48 M mysql-community-common x86_64 8.0.21-1.el7 mysql80-community 617 k ncurses-compat-libs x86_64 6.0-8.20170212.amzn2.1.3 amzn2-core 308 k Transaction Summary ================================================================================================================================================================== Install 3 Packages (+3 Dependent packages) Total download size: 553 M Is this ok [y/d/N]: y ..... Total 2.3 MB/s | 553 MB 00:03:59 Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql Importing GPG key 0x5072E1F5: Userid : "MySQL Release Engineering <[email protected]>" Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5 Package : mysql80-community-release-el7-3.noarch (installed) From : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql Is this ok [y/N]: y
Core packages installed are:
- MySQL server: mysql-community-server
- MySQL client: mysql-community-client
- Common error messages and character sets for client and server: mysql-community-common
- Shared client libraries: mysql-community-libs
Step 3: Start and Configure MySQL 8 on Amazon Linux 2
The next step is to start MySQL server services.
sudo systemctl enable --now mysqld
Confirm if MySQL server service is started and running.
$ systemctl status mysqld ● mysqld.service - MySQL Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled) Active: active (running) since Wed 2020-08-12 17:25:38 UTC; 7s ago Docs: man:mysqld(8) http://dev.mysql.com/doc/refman/en/using-systemd.html Process: 4807 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS) Main PID: 4880 (mysqld) Status: "Server is operational" CGroup: /system.slice/mysqld.service └─4880 /usr/sbin/mysqld Aug 12 17:25:33 amazon-linux systemd: Starting MySQL Server... Aug 12 17:25:38 amazon-linux systemd: Started MySQL Server.
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:
$ sudo grep 'temporary password' /var/log/mysqld.log 2020-08-12T17:25:34.992227Z 6 [Note] [MY-010454] [Server] A temporary password is generated for [email protected]: BEw-U?DV,7eO
Use this initial password to harden the server.
$ sudo mysql_secure_installation -p'BEw-U?DV,7eO'
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: Re-enter 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) : ... skipping. 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 environment. Remove anonymous users? (Press y|Y for Yes, any other key for No) : y Success. 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 Success. 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 environment. Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y - Dropping test database... Success. - Removing privileges on test database... Success. 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 Success. All done!
You can update root password anytime from MySQL shell.
$ mysql -uroot -p mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '[email protected]!';
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.