Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»Linux Distributions»Amazon Linux»How to Install MySQL 5.7 on Amazon Linux

    How to Install MySQL 5.7 on Amazon Linux

    RahulBy RahulJune 11, 20194 Mins ReadUpdated:October 31, 2020

    MySQL is a relational database system. In our previous tutorial, you installed Apache and PHP on Amazon Linux. This tutorial will help you to install MySQL 5.7 on Amazon Linux systems.

    Prerequisites

    Login to your Fedora system and open a terminal. Now upgrade the current packages to the latest version by running the following command.

    sudo yum update -y 
    

    Step 1 – Install MySQL on Amazon Linux

    The Amazon Linux default repositories contains Mariadb packages for the installation. To install MySQL community relese, first configure MySQL yum repository on your machine.

    sudo rpm -Uvh https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm 
    

    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 
    
    Dependencies Resolved                                                                                 
    
    ============================================================================================================
     Package                             Arch           Version                     Repository             Size
    ============================================================================================================
    Installing:                                                                                           
     mysql-community-libs                x86_64         5.7.32-1.el7                mysql57-community     2.3 M
         replacing  mariadb-libs.x86_64 1:5.5.68-1.amzn2                                                  
     mysql-community-libs-compat         x86_64         5.7.32-1.el7                mysql57-community     1.2 M
         replacing  mariadb-libs.x86_64 1:5.5.68-1.amzn2                                                  
     mysql-community-server              x86_64         5.7.32-1.el7                mysql57-community     173 M
    Installing for dependencies:                                                                          
     mysql-community-client              x86_64         5.7.32-1.el7                mysql57-community      25 M
     mysql-community-common              x86_64         5.7.32-1.el7                mysql57-community     308 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: 203 M                                                                            
    Is this ok [y/d/N]: y
    

    Press ‘y’ when prompt for the confirmation to complete installation.

    Once the MySQL installation completed on your Amazon Linux system. You need to enable the MySQL service to start on system boot. Also, start service using the following commands:

    sudo systemctl enable mysqld 
    sudo systemctl start mysqld 
    

    Once you start 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 
    
    2020-10-31T06:37:32.258128Z 1 [Note] A temporary password is generated for [email protected]: /c5>WMwMHmaV
    

    Copy this password and use this for the post-installation setup wizard.

    Step 2 – Post Installation Setup

    The MySQL community server has been installed on your system. Now run the following command to apply security on MySQL server. Simply execute below command and follow the security wizard.

    sudo mysql_secure_installation 
    

    Enter the root password found in above step, then set a new password for mysql root account. Next, follow the onscreen instructions and Press Y for all other operations to apply improved security.

    Securing the MySQL server deployment.
    
    Enter password for user root:
    
    The existing password for the user account root has expired. Please set a new password.
    
    New password:
    
    Re-enter new password:
    The 'validate_password' plugin is installed on the server.
    The subsequent steps will run with the existing configuration
    of the plugin.
    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) : n
    
     ... 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!
    

    Step 3 – Connect MySQL Terminal

    All done. You can now connect to the MySQL server using the command line. The following command will connect MySQL running on localhost as the root user. This will prompt for the root account password.

    mysql -u root -p
    
    Enter password:
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 5
    Server version: 5.7.32 MySQL Community Server (GPL)
    
    Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
    
    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>
    
    

    Conclusion

    In this tutorial, you have learned to install MySQL community server on a Amazon Linux 2 system.

    Amazon Linux MySQL
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleHow to Create Your Angular Application with Angular CLI
    Next Article How to Install Apache 2.4 & PHP 7.4 on Amazon Linux

    Related Posts

    Backup MySQL Databases to Amazon S3 (Shell Script)

    Updated:May 28, 20222 Mins Read

    How to Install MariaDB on Ubuntu 22.04

    Updated:May 28, 20222 Mins Read

    How To Install Linux, Nginx, MySQL, & PHP (LEMP Stack) on Ubuntu 22.04

    Updated:April 7, 20227 Mins Read

    How To Install MySQL Server on Ubuntu 22.04

    Updated:April 6, 20224 Mins Read

    How to Install Apache, MySQL, PHP (LAMP Stack) on Ubuntu 22.04

    Updated:June 28, 20225 Mins Read

    How To Install MariaDB on Debian 11

    4 Mins Read

    7 Comments

    1. Sunil on April 13, 2021 12:50 pm

      Thank you Rahul

      Reply
    2. Ashish on February 5, 2021 8:57 pm

      Good one

      Reply
    3. Atli Cervantes on December 13, 2020 2:31 am

      You rock!!!

      Reply
    4. Juarez on October 9, 2020 12:25 pm

      Hey Rahul!
      … good job.
      Thank you!

      Reply
    5. Maruthi on September 26, 2019 4:16 am

      Thanks for this article.
      I had to do small changes to installation steps, please update for benefit of others

      wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
      sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm
      yum update
      yum install mysql-server

      Reply
    6. Madan Kumar T on July 4, 2019 10:52 am

      Hi Rahul ,
      thank you for the documentation it is very nice , how to handle mysql_secure_installation using script

      Reply
    7. Anoop Srivastava on June 16, 2019 3:26 pm

      Thanks Rahul. You have done a great job, now it is really easy to install.

      Looking forward for your next post.

      Reply

    Leave A Reply Cancel Reply

    Recent Posts
    • What is the /etc/nsswitch.conf file in Linux
    • How to Install Ionic Framework on Ubuntu 22.04
    • What is the /etc/hosts file in Linux
    • How to Install Angular CLI on Ubuntu 22.04
    • How to Install Composer on Ubuntu 22.04
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

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