[MySQL][Install] - 8.0+CentOS 7.x-RPM 설치

1.패키지 다운로드를 위한 repository 설치 

centos, rhel은 편리하게 yum이라는 패키지 매니저를 제공해줍니다. 이 패키지 매니저를 이용해서 설치하면 편리하게 설치가 가능합니다. 

여기에서는 CentOS 7에서 설치하는 방법을 알아봅니다. 

 

먼저 다음사이트에 접속합니다.  

https://dev.mysql.com/downloads/repo/yum/ 

 

사이트에 방문 후 밑에 보시면 os에 따른 다운로드 버튼이 있는데 rhel6 혹은 7을 자신의 버전에 맞는 패키지로 다운로드 합니다. 참고로 centos6는 rhel 6, centos 7은 rhel7으로 받으시면 됩니다. 

 

다운로드한 rpm패키지를 설치합니다. 

shell > rpm -Uvh mysql80-community-release-el7-3.noarch.rpm
warning: mysql80-community-release-el7-3.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql80-community-release-el7-3  ################################# [100%]

 

설치는 바로 끝이납니다. 이것은 mysql을 설치한것이 아니라 repository라는 저장소를 추가하는 것입니다. 이 저장소에서 원하는 버전의 Mysql을 로컬 서버로 다운로드하여 설치하는 것입니다. 

 

2. repository 확인 및 버전 확인

설치된 내용을 확인합니다. 

shell > rpm -qa | grep -i mysql
mysql80-community-release-el7-3.noarch

이와 비슷하게 화면이 출력됩니다. 

 

이렇게 화면에 출력이 되면 Mysql을 다운로드 할 repository를 추가하게 된것 입니다. 

실제로 repository가 추가되었는지 확인해 보겠습니다. 

shell> yum repolist enabled | grep -i "mysql.*-community.*" 
mysql-connectors-community/x86_64       MySQL Connectors Community           131
mysql-tools-community/x86_64            MySQL Tools Community                100
mysql80-community/x86_64                MySQL 8.0 Community Server           145

 

여러 버전이 출력되는것을 확인해보실 수 있습니다.  우리는 8.0을 설치할 것이기 때문에 이대로 진행합니다.

기본으로 사용할 수 있도록 설정이 되어 있습니다.

 

mysql80-community/x86_64                MySQL 8.0 Community Server           145

위와 같이 맨 끝에 숫자가 표시되어 있으면 이것을 사용하겠다는 뜻입니다.

 

그렇다면 과연 설치가 가능하도록 환경이 구성되었는지 확인해 보도록 하겠습니다. 

shell > cat /etc/yum.repos.d/mysql-community.repo

그럼 다음과 같은 화면이 출력됩니다.

 

[mysql80-community]
name=MySQL 8.0 Community Server
baseurl=http://repo.mysql.com/yum/mysql-8.0-community/el/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

 

여기서 주목해서 볼것이 enabled입니다. 이게 disabled로 되어있으면 사용하지 않겠다는 것이 됩니다. 

 

마지막으로 내가 설치할 버전의 repository가 설정이 되어있는지 확인해 보겠습니다. 

shell> yum repolist enabled | grep mysql 

사용가능한 리스트들만이 출력됩니다.

 

 

 

3.MySQL 설치 

repository 환경설정이 끝났으니 이제 본격적으로 rpm을 이용한 설치를 진행해보겠습니다.

먼저 설치 가능한 리스트를 확인해 봅니다.

shell > yum search mysql-community
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.navercorp.com
 * extras: mirror.kakao.com
 * updates: mirror.kakao.com
================================= N/S matched: mysql-community=================================
mysql-community-client.i686 : MySQL database client applications and tools
mysql-community-client.x86_64 : MySQL database client applications and tools
mysql-community-common.i686 : MySQL database common files for server and client libs
mysql-community-common.x86_64 : MySQL database common files for server and client libs
mysql-community-devel.i686 : Development header files and libraries for MySQL database client applications
mysql-community-devel.x86_64 : Development header files and libraries for MySQL database client applications
mysql-community-embedded-compat.i686 : MySQL embedded compat library
mysql-community-embedded-compat.x86_64 : MySQL embedded compat library
mysql-community-libs.i686 : Shared libraries for MySQL database client applications
mysql-community-libs.x86_64 : Shared libraries for MySQL database client applications
mysql-community-libs-compat.i686 : Shared compat libraries for MySQL 5.6.37 database client applications
mysql-community-libs-compat.x86_64 : Shared compat libraries for MySQL 5.6.45 database client applications
mysql-community-release.noarch : MySQL repository configuration for yum
mysql-community-server.x86_64 : A very fast and reliable SQL database server
mysql-community-test.x86_64 : Test suite for the MySQL database server

  Name and summary matches only, use "search all" for everything.

 

MySQL Server를 설치해 보겠습니다.

shell> sudo yum install mysql-community-server

패키지 설치 확인을 물어볼때 'y'를 입력하고 이렇게 하면 설치가 진행되고 완료가 됩니다.

 

4. MySQL서버 시작 및 접속 

다음 명령어로 MySQL을 시작합니다. 

shell> systemctl start mysqld

 

서버의 상태가 어떤지 체크해 봅니다. 

shell> systemctl status mysqld
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Sat 2019-12-28 22:38:48 KST; 15s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 8857 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 8937 (mysqld)
   Status: "Server is operational"
   CGroup: /system.slice/mysqld.service
           └─8937 /usr/sbin/mysqld

Dec 28 22:38:41 my80rpm systemd[1]: Starting MySQL Server...
Dec 28 22:38:48 my80rpm systemd[1]: Started MySQL Server.

 

서버에 접속해 봅니다. 그런데 최고 유저인 root 유저를 알지 못합니다. 다음과 같은 방법으로 root유저의 암호를 찾아봅니다. 

shell> grep 'temporary password' /var/log/mysqld.log 
2019-12-28T13:38:45.564542Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: aAKVoqG,g8/,

이렇게 하면 초기 root 암호를 알 수 있습니다. 

 

자 이제 서버에 접속해 봅니다. 

shell> mysql -uroot -p 
enter password :

 

이렇게 하면 암호를 물어보는데 여기에 전에 알아낸 암호를 입력합니다. 

그러면 서버에 접속한것을 확인할 수 있습니다. 

 

이제 root 암호를 나만의 암호로 바꾸어 줍니다. 

참고로 강력한 암호(숫자.영문.영문대문자.특수문자등이)가 설정되지 않으면 다음과 같은 에러가 발생합니다. 

mysql > ALTER USER 'root'@'localhost' IDENTIFIED BY ‘admin1234'; 
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

 

초기 암호 정책에 따라 대소문자,특수문자,숫자가 반드시 혼용되어 사용되어야 합니다.

mysql> alter user 'root'@'localhost' identified by '!MyNewPass4';

이렇게 하면 root 암호가 변경됩니다. 

 

5. 기타 지원 패키지 설치하기. 

MYSQL서버 말고도 client같은 터미널 접속 패키지와 jdbc connectot, odbc같은 개발환경 패키지도 다운로드 받아야 합니다. 그러나 이 패키지들은 또다른 서브 repository에 존재합니다. 다음과 같은 yum 명령을 수행합니다. 

shell> sudo yum --disablerepo=\* --enablerepo='mysql*-community*' list available

 

이렇게 하면 sub repository에 필요 패키지들을 다운로드 할 수 있습니다. 

 

서브 패키지를 설치하려면 먼저 설치할 리스트를 확인합니다. 

shell > yum repolist all | grep -i mysql
mysql-cluster-7.5-community/x86_64 MySQL Cluster 7.5 Community   disabled
mysql-cluster-7.5-community-source MySQL Cluster 7.5 Community - disabled
mysql-cluster-7.6-community/x86_64 MySQL Cluster 7.6 Community   disabled
mysql-cluster-7.6-community-source MySQL Cluster 7.6 Community - disabled
mysql-cluster-8.0-community/x86_64 MySQL Cluster 8.0 Community   disabled
mysql-cluster-8.0-community-source MySQL Cluster 8.0 Community - disabled
mysql-connectors-community/x86_64  MySQL Connectors Community    enabled:    131
mysql-connectors-community-source  MySQL Connectors Community -  disabled
mysql-tools-community/x86_64       MySQL Tools Community         enabled:    100
mysql-tools-community-source       MySQL Tools Community - Sourc disabled
mysql-tools-preview/x86_64         MySQL Tools Preview           disabled
mysql-tools-preview-source         MySQL Tools Preview - Source  disabled
mysql55-community/x86_64           MySQL 5.5 Community Server    disabled
mysql55-community-source           MySQL 5.5 Community Server -  disabled
mysql56-community/x86_64           MySQL 5.6 Community Server    disabled
mysql56-community-source           MySQL 5.6 Community Server -  disabled
mysql57-community/x86_64           MySQL 5.7 Community Server    disabled
mysql57-community-source           MySQL 5.7 Community Server -  disabled
mysql80-community/x86_64           MySQL 8.0 Community Server    enabled:    145
mysql80-community-source           MySQL 8.0 Community Server -  disabled

 

설치할 패키지 이름을 확인합니다. 

shell> yum list | grep -i mysql80-community   
mysql-community-client.x86_64               8.0.18-1.el7               @mysql80-community
mysql-community-common.x86_64               8.0.18-1.el7               @mysql80-community
mysql-community-libs.x86_64                 8.0.18-1.el7               @mysql80-community
mysql-community-libs-compat.x86_64          8.0.18-1.el7               @mysql80-community
mysql-community-server.x86_64               8.0.18-1.el7               @mysql80-community
mysql80-community-release.noarch            el7-3                      installed
mysql-community-client.i686                 8.0.18-1.el7               mysql80-community
mysql-community-common.i686                 8.0.18-1.el7               mysql80-community
mysql-community-devel.i686                  8.0.18-1.el7               mysql80-community
mysql-community-devel.x86_64                8.0.18-1.el7               mysql80-community
mysql-community-embedded-compat.i686        8.0.18-1.el7               mysql80-community
mysql-community-embedded-compat.x86_64      8.0.18-1.el7               mysql80-community
mysql-community-libs.i686                   8.0.18-1.el7               mysql80-community
mysql-community-libs-compat.i686            8.0.18-1.el7               mysql80-community
mysql-community-test.x86_64                 8.0.18-1.el7               mysql80-community
mysql-ref-manual-8.0-en-html-chapter.noarch 1-20190923                 mysql80-community
mysql-ref-manual-8.0-en-pdf.noarch          1-20190923                 mysql80-community

 

설치할 패키지를 확인하고 설치합니다. 

shell > yum install mysql-community-devel

패키지 설치 진행 여부에서 'y'를 입력하면 패키지 설치가 진행되고 종료됩니다.

 

6. 원격 설정 

centos, rhel은 기본적으로 방화벽이 설정되어 있습니다. 그래서 Mysql이 접속할 수 있도록 port를 오픈해 주어야 접속이 가능합니다. 기본 포트는 3306입니다. 

 

다음과 같이 입력해 줍니다. 

* centos6 
iptables -A INPUT -p tcp --dport 3306 -j ACCEPT  

* centos7 
firewall-cmd --permanent --zone=dmz --add-service=mysql 
firewall-cmd --permanent --zone=public --add-port=3306/tcp 
firewall-cmd --reload 
firewall-cmd --list-ports

이래야 원격에서 mysql을 접속할 수 있습니다. 

 

※도움이 되셨다면 광고클릭 한번 부탁드립니다.※

Designed by JB FACTORY