본문 바로가기
DB/MySQL

(DB) CentOS7 버전 MySQL 5.7 설치

by 미니몬 2023. 9. 6.

목차

    728x90
    반응형

    CentOS 7 버전 MySQL 5.7 설치 방법

    이번 블로그 게시물에서는 CentOS 7 서버에 MySQL 5.7 버전을 설치하고 보안 설정을 수행하는 절차를 소개합니다. 

    MySQL은 오픈 소스 관계형 데이터베이스 관리 시스템으로, 다양한 웹 애플리케이션 및 서버에서 데이터를 관리하는 데 사용됩니다.

     

     

    1) MySQL 설치 파일 다운로드

    먼저 MySQL 5.7 커뮤니티 버전의 RPM 파일을 다운로드합니다. 아래 명령을 실행하여 다운로드합니다.

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

     

    2) GPG 키 추가

    MySQL RPM 파일의 유효성을 확인하기 위해 MySQL RPM GPG 키를 추가합니다. 

    rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022

     

     

    3) RPM 파일 설치

    다운로드한 RPM 파일을 설치합니다. 다음 명령을 실행하여 설치합니다.

    rpm -ivh mysql57-community-release-el7-11.noarch.rpm

     

     

    4) MySQL 서버 설치

    MySQL 서버를 설치합니다. 아래 명령을 실행하여 설치합니다.

    yum install -y mysql-server

     

     

    5) MySQL 서비스 시작 및 부팅 시 자동 실행 설정

    MySQL 서버를 시작하고 부팅 시 자동으로 실행되도록 설정합니다.

    systemctl start mysqld
    systemctl enable mysqld

     

     

    6) 보안 설정

    MySQL 보안 설정을 수행합니다. 다음 명령을 실행하여 MySQL 보안 설정을 수행합니다.

    mysql_secure_installation

     

    보안 설정 과정에서는 다음과 같은 단계를 수행합니다 :

    • 현재 root 사용자의 비밀번호 확인 - [ enter ]
    NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
          SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
    
    In order to log into MariaDB to secure it, we'll need the current
    password for the root user. If you've just installed MariaDB, and
    haven't set the root password yet, you should just press enter here.
    
    Enter current password for root (enter for none): 
    OK, successfully used password, moving on...

     

    • unix_socket 인증 설정 변경 - [ n ]
    Setting the root password or using the unix_socket ensures that nobody
    can log into the MariaDB root user without the proper authorisation.
    
    You already have your root account protected, so you can safely answer 'n'.
    
    Switch to unix_socket authentication [Y/n] n  
     ... skipping.

     

    • 루트 비밀번호 변경 여부 선택 - [ n ]
    You already have your root account protected, so you can safely answer 'n'.
    
    Change the root password? [Y/n] n
     ... skipping.

     

    • 익명 사용자 제거 - [ y ]
    By default, a MariaDB installation has an anonymous user, allowing anyone
    to log into MariaDB 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? [Y/n] Y
     ... Success!

     

    • 격에서 root 로그인 허용 여부 선택 - [ n ]
    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? [Y/n] n
     ... skipping.

     

    • 테스트 데이터베이스 제거 - [ y ]
    By default, MariaDB 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? [Y/n] Y
     - Dropping test database...
     ... Success!
     - Removing privileges on test database...
     ... Success!

     

    • 권한 테이블 다시 로드 - [ y ]
    Reloading the privilege tables will ensure that all changes made so far
    will take effect immediately.
    
    Reload privilege tables now? [Y/n] Y
     ... Success!
    
    Cleaning up...
    
    All done!  If you've completed all of the above steps, your MariaDB
    installation should now be secure.
    
    Thanks for using MariaDB!

     

     

     

    7) MySQL 접속

    mysql -u root -p

     

    이렇게 설치하면 이상없이 Mysql 접속이 될 것 입니다.

    하지만 초기 패스워드가 없이 그냥 접속되기 때문에 다음 게시물에서는 비밀번호 설정 방법에 대해 알아보도록 하겠습니다.

     

     

    728x90
    반응형