Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Databases»MySQL»How To Install MySQL 8 on Amazon Linux 2

    How To Install MySQL 8 on Amazon Linux 2

    By RahulSeptember 6, 20226 Mins Read

    MySQL is a very popular open-source relational database management system that can run on Linux, Windows, and Mac OS. It’s typically used as the back-end database for web applications, though it can also be used to store data for other software. You can use MySQL to store and organize data, retrieve it when needed, and transform it into a different format (e.g. changing it from text to numbers). It’s commonly used by companies of all sizes as the database for their websites and applications.

    Advertisement

    This article will walk through the process of installing MySQL 8 on Amazon Linux 2. When you’re finished, you’ll have a fully-functioning MySQL database that you can use with either the AWS Console or your own application. You can also use Amazon RDS to configure other databases besides MySQL.

    How to Install MySQL 8 on Amazon Linux

    The MySQL official team provides the RPM packages for the installation of Amazon Linux systems. Follow the below steps one by one to complete the MySQL installation.

    1. Configure Yum Repository
    2. Most of the packages required the dependencies that are available in other third-party repositories. Use the following command to configure the EPEL repository that is required for package installation.

      sudo amazon-linux-extras install epel -y 
      

      Then configure the MySQL repository by installing the package provided by the MySQL official site.

      sudo yum install https://dev.mysql.com/get/mysql80-community-release-el7-5.noarch.rpm 
      

    3. Install MySQL Server
    4. You can successfully configure the repositories, your system is ready for MySQL installation. Execute the below-mentioned command to install MySQL 8 community server on Amazon Linux.

      sudo yum install mysql-community-server 
      

      Press ‘y’ for the confirmation prompted during the installation.

      How to Install MySQL 8 on Amazon Linux 2
      MySQL pacakges installation on Amazon Linux 2

    5. Activate and Start MySQL Service
    6. Once the installation is successfully finished. The default MySQL service will be stopped and in an inactive state. First, use the following commands to activate the service to auto-start on system startup, then start it manually for the first time.

      systemctl active mysqld 
      systemctl start mysqld 
      

      Then, use the following command to view the MySQL service status. It should be active and running.

      systemctl status mysqld 
      
      How to Install MySQL 8 on Amazon Linux 2
      Activate and start MySQL service

    7. Find initial root password
    8. During the installation of packages, an initial password is configured for the MySQL root account. You can find this password from the MySQL log file.

      cat /var/log/mysql.log | grep "A temporary password" 
      

      You will see the output below that includes the default root password.

      How to Install MySQL 8 on Amazon Linux 2
      Getting the default root password after installation

      This password will be required in the next step.

    9. MySQL Post Installation Setup
    10. A post-installation script is provided by the MySQL packages. That is helpful for configuring MySQL once after the installation. This helps us to configure a strong root account password, remote anonymous users, disallow root access remotely and remove the test database.

      Execute the following command from the terminal:

      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.

      • Enter password for user root: [Enter current root password]
      • New password: [Enter a new root password]
      • Re-enter new password: [Re-Enter the new root password]
      • Estimated strength of the password: 100
        Change the password for root ? ((Press y|Y for Yes, any other key for No) : n
      • Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
      • Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
      • Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
      • Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
      • All done!

    11. Connect to MySQL
    12. Your MySQL server is ready to use now. From the terminal, you can run the below command to connect to the MySQL command line interface. It will prompt for the root account password. On successful authentication, you will get the MySQL prompt.

      mysql -u root -p 
      

      Enter the MySQL root user password:

      Output:
      Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 14 Server version: 8.0.30 MySQL Community Server - GPL Copyright (c) 2000, 2022, Oracle and/or its affiliates. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>

      Here you can create databases, tables, users, and all the required things by using the structured query language statements.

    Next Steps for Maintaining MySQL

    As you’re setting up your new database, it’s a good idea to put some thought into how you will maintain the database in the long term. This guide focuses on setting up a new database, but you should also consider ways to make your database more automated and easier to manage. One simple way to do this is to automate the process of backing up your database. This will allow you to keep a copy of your data in case something goes wrong and you need to restore it from a previous point in time. This can be done with the help of some simple scripts that call the MySQL database and write the data to a different location.

    We already have created a simple database backup script and one advance MySQL database backup script for the purpose. You can use these scripts to quickly configure the database backups.

    Final Words

    There are many reasons why you might want to run your database on Amazon’s cloud. Some common ones have cost, ease of setup and maintenance, and the ability to scale up or down as needed. Running your database on Amazon Linux has a few advantages over using a different Linux distribution. Amazon has thoroughly tested its distribution and it is optimized for running on its cloud infrastructure. When you’re setting up a new database, it’s important to choose a solution that meets your needs and can grow with your business.

    This guide focuses on installing MySQL on Amazon Linux, which is one of the easiest and most cost-effective ways to get a new database up and running.

    Amazon Linux 2 database MySQL MySQL 8.0 mysql-server
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    (Resolved) MySQL connection error: certificate verify failed

    How to Connect Python with MySQL Database

    (Resolved) Unknown collation: utf8mb4_unicode_520_ci

    Add A Comment

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • tail Command in Linux with Examples
    • What is a Orphan Process in Unix/Linux
    • How To Display Warning Message to Unauthorized SSH Access
    • How to Set a Custom SSH Login Banner and MOTD
    • Understanding Reverse DNS: What it is and Why it Matters?
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.