상세 컨텐츠

본문 제목

MySQL 5.7 설치 및 초기 설정

IT/MySQL

2020. 11. 22. 22:48

본문

 

◎ MySQL 5.7 CentOS 설치 및 초기 설정

 

○ MySQL Package 다운로드

- MySQL Package 다운로드

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

--2020-11-22 00:30:27-- https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
Resolving dev.mysql.com (dev.mysql.com)... 137.254.60.11
Connecting to dev.mysql.com (dev.mysql.com)|137.254.60.11|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm [following]
--2020-11-22 00:30:28-- https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm
Resolving repo.mysql.com (repo.mysql.com)... 23.43.10.53
Connecting to repo.mysql.com (repo.mysql.com)|23.43.10.53|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 25680 (25K) [application/x-redhat-package-manager]
Saving to: ‘mysql57-community-release-el7-11.noarch.rpm’
100%[======================================>] 25,680 --.-K/s in 0.007s
2020-11-22 00:30:29 (3.37 MB/s) - ‘mysql57-community-release-el7-11.noarch.rpm’ saved [25680/25680]

 

○ MySQL Package 설치

- MySQL Package 설치

$ sudo rpm -Uvh mysql57-community-release-el7-11.noarch.rpm

경고: mysql57-community-release-el7-11.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
준비 중... ################################# [100%]
Updating / installing... 1:mysql57-community-release-el7-11 ################################ [100%]

 

- yum repository list에서 mysql 설치 조회

$ yum repolist all | grep 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-connectors-community/x86_64   MySQL Connectors Community  enabled:     175
mysql-connectors-community-source   MySQL Connectors Community - disabled
mysql-tools-community/x86_64           MySQL Tools Community          enabled:    120
mysql-tools-community-source           MySQL Tools Community - Sour 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   enabled:      464
mysql57-community-source               MySQL 5.7 Community Server - disabled
mysql80-community/x86_64               MySQL 8.0 Community Server   disabled
mysql80-community-source               MySQL 8.0 Community Server - disabled

 

○ MySQL Server 설치

- MySQL Server 설치

$ sudo yum install mysql-community-server

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.kakao.com
 * extras: mirror.kakao.com
 * updates: mirror.kakao.com
mysql-connectors-community                                                        | 2.6 kB  00:00:00
mysql-tools-community                                                                | 2.6 kB  00:00:00
mysql57-community                                                                    | 2.6 kB  00:00:00
(1/3): mysql-tools-community/x86_64/primary_db                               |  83 kB  00:00:00
(2/3): mysql57-community/x86_64/primary_db                                   | 247 kB  00:00:00
(3/3): mysql-connectors-community/x86_64/primary_db                       |  68 kB  00:00:00
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:5.7.32-1.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.7.32-1.el7 for package: mysql-community-server-5.7.32-1.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 5.7.9 for package: mysql-community-server-5.7.32-1.el7.x86_64
--> Processing Dependency: /usr/bin/perl for package: mysql-community-server-5.7.32-1.el7.x86_64
--> Processing Dependency: net-tools for package: mysql-community-server-5.7.32-1.el7.x86_64
--> Processing Dependency: perl(Getopt::Long) for package: mysql-community-server-5.7.32-1.el7.x86_64
--> Processing Dependency: perl(strict) for package: mysql-community-server-5.7.32-1.el7.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:5.7.32-1.el7 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 5.7.9 for package: mysql-community-client-5.7.32-1.el7.x86_64
---> Package mysql-community-common.x86_64 0:5.7.32-1.el7 will be installed
---> Package net-tools.x86_64 0:2.0-0.25.20131004git.el7 will be installed
---> Package perl.x86_64 4:5.16.3-297.el7 will be installed
--> Processing Dependency: perl-libs = 4:5.16.3-297.el7 for package: 4:perl-5.16.3-297.el7.x86_64
--> Processing Dependency: perl(Socket) >= 1.3 for package: 4:perl-5.16.3-297.el7.x86_64
--> Processing Dependency: perl(Scalar::Util) >= 1.10 for package: 4:perl-5.16.3-297.el7.x86_64
--> Processing Dependency: perl-macros for package: 4:perl-5.16.3-297.el7.x86_64
--> Processing Dependency: perl-libs for package: 4:perl-5.16.3-297.el7.x86_64
--> Processing Dependency: perl(threads::shared) for package: 4:perl-5.16.3-297.el7.x86_64
--> Processing Dependency: perl(threads) for package: 4:perl-5.16.3-297.el7.x86_64
--> Processing Dependency: perl(constant) for package: 4:perl-5.16.3-297.el7.x86_64
--> Processing Dependency: perl(Time::Local) for package: 4:perl-5.16.3-297.el7.x86_64
--> Processing Dependency: perl(Time::HiRes) for package: 4:perl-5.16.3-297.el7.x86_64
--> Processing Dependency: perl(Storable) for package: 4:perl-5.16.3-297.el7.x86_64
--> Processing Dependency: perl(Socket) for package: 4:perl-5.16.3-297.el7.x86_64
--> Processing Dependency: perl(Scalar::Util) for package: 4:perl-5.16.3-297.el7.x86_64
--> Processing Dependency: perl(Pod::Simple::XHTML) for package: 4:perl-5.16.3-297.el7.x86_64
--> Processing Dependency: perl(Pod::Simple::Search) for package: 4:perl-5.16.3-297.el7.x86_64
--> Processing Dependency: perl(Filter::Util::Call) for package: 4:perl-5.16.3-297.el7.x86_64
--> Processing Dependency: perl(File::Temp) for package: 4:perl-5.16.3-297.el7.x86_64
--> Processing Dependency: perl(File::Spec::Unix) for package: 4:perl-5.16.3-297.el7.x86_64
--> Processing Dependency: perl(File::Spec::Functions) for package: 4:perl-5.16.3-297.el7.x86_64
--> Processing Dependency: perl(File::Spec) for package: 4:perl-5.16.3-297.el7.x86_64
--> Processing Dependency: perl(File::Path) for package: 4:perl-5.16.3-297.el7.x86_64
--> Processing Dependency: perl(Exporter) for package: 4:perl-5.16.3-297.el7.x86_64
--> Processing Dependency: perl(Cwd) for package: 4:perl-5.16.3-297.el7.x86_64
--> Processing Dependency: perl(Carp) for package: 4:perl-5.16.3-297.el7.x86_64
--> Processing Dependency: libperl.so()(64bit) for package: 4:perl-5.16.3-297.el7.x86_64
---> Package perl-Getopt-Long.noarch 0:2.40-3.el7 will be installed
--> Processing Dependency: perl(Pod::Usage) >= 1.14 for package: perl-Getopt-Long-2.40-3.el7.noarch
--> Processing Dependency: perl(Text::ParseWords) for package: perl-Getopt-Long-2.40-3.el7.noarch
--> Running transaction check---> Package mariadb-libs.x86_64 1:5.5.65-1.el7 will be obsoleted
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-9.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-9.el7.x86_64
---> Package mysql-community-libs.x86_64 0:5.7.32-1.el7 will be obsoleting
---> Package perl-Carp.noarch 0:1.26-244.el7 will be installed
---> Package perl-Exporter.noarch 0:5.68-3.el7 will be installed
---> Package perl-File-Path.noarch 0:2.09-2.el7 will be installed
---> Package perl-File-Temp.noarch 0:0.23.01-3.el7 will be installed
---> Package perl-Filter.x86_64 0:1.49-3.el7 will be installed
---> Package perl-PathTools.x86_64 0:3.40-5.el7 will be installed
---> Package perl-Pod-Simple.noarch 1:3.28-4.el7 will be installed
--> Processing Dependency: perl(Pod::Escapes) >= 1.04 for package: 1:perl-Pod-Simple-3.28-4.el7.noarch
--> Processing Dependency: perl(Encode) for package: 1:perl-Pod-Simple-3.28-4.el7.noarch
---> Package perl-Pod-Usage.noarch 0:1.63-3.el7 will be installed
--> Processing Dependency: perl(Pod::Text) >= 3.15 for package: perl-Pod-Usage-1.63-3.el7.noarch
--> Processing Dependency: perl-Pod-Perldoc for package: perl-Pod-Usage-1.63-3.el7.noarch
---> Package perl-Scalar-List-Utils.x86_64 0:1.27-248.el7 will be installed
---> Package perl-Socket.x86_64 0:2.010-5.el7 will be installed
---> Package perl-Storable.x86_64 0:2.45-3.el7 will be installed
---> Package perl-Text-ParseWords.noarch 0:3.29-4.el7 will be installed
---> Package perl-Time-HiRes.x86_64 4:1.9725-3.el7 will be installed
---> Package perl-Time-Local.noarch 0:1.2300-2.el7 will be installed
---> Package perl-constant.noarch 0:1.27-2.el7 will be installed
---> Package perl-libs.x86_64 4:5.16.3-297.el7 will be installed
---> Package perl-macros.x86_64 4:5.16.3-297.el7 will be installed
---> Package perl-threads.x86_64 0:1.87-4.el7 will be installed
---> Package perl-threads-shared.x86_64 0:1.43-6.el7 will be installed
--> Running transaction check
---> Package mysql-community-libs-compat.x86_64 0:5.7.32-1.el7 will be obsoleting
---> Package perl-Encode.x86_64 0:2.51-7.el7 will be installed
---> Package perl-Pod-Escapes.noarch 1:1.04-297.el7 will be installed
---> Package perl-Pod-Perldoc.noarch 0:3.20-4.el7 will be installed
--> Processing Dependency: perl(parent) for package: perl-Pod-Perldoc-3.20-4.el7.noarch
--> Processing Dependency: perl(HTTP::Tiny) for package: perl-Pod-Perldoc-3.20-4.el7.noarch
---> Package perl-podlators.noarch 0:2.5.1-3.el7 will be installed
--> Running transaction check---> Package perl-HTTP-Tiny.noarch 0:0.033-3.el7 will be installed
---> Package perl-parent.noarch 1:0.225-244.el7 will be installed
--> Finished Dependency Resolution
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.65-1.el7
 mysql-community-libs-compat   x86_64      5.7.32-1.el7        mysql57-community    1.2 M
   replacing  mariadb-libs.x86_64 1:5.5.65-1.el7
 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
  net-tools                               x86_64      2.0-0.25.20131004git.el7   base            306 k
  perl                                      x86_64     4:5.16.3-297.el7   base                        8.0 M
  perl-Carp                               noarch     1.26-244.el7       base                         19 k
  perl-Encode                            x86_64     2.51-7.el7          base                        1.5 M
  perl-Exporter                          noarch      5.68-3.el7          base                         28 k
  perl-File-Path                          noarc       2.09-2.el7          base                         26 k
  perl-File-Temp                        noarch      0.23.01-3.el7      base                         56 k
  perl-Filter                               x86_64     1.49-3.el7          base                         76 k
  perl-Getopt-Long                     noarch     2.40-3.el7          base                         56 k
  perl-HTTP-Tiny                        noarch     0.033-3.el7         base                         38 k
  perl-PathTools                         x86_64     3.40-5.el7          base                         82 k
  perl-Pod-Escapes                     noarch     1:1.04-297.el7     base                         52 k
  perl-Pod-Perldoc                     noarch      3.20-4.el7          base                         87 k
  perl-Pod-Simple                      noarch      1:3.28-4.el7        base                       216 k
  perl-Pod-Usage                       noarch      1.63-3.el7          base                         27 k
  perl-Scalar-List-Utils                 x86_64      1.27-248.el7       base                         36 k
  perl-Socket                            x86_64      2.010-5.el7         base                         49 k
  perl-Storable                          x86_64      2.45-3.el7          base                         77 k
  perl-Text-ParseWords               noarch      3.29-4.el7          base                         14 k
  perl-Time-HiRes                      x86_64      4:1.9725-3.el7     base                         45 k
  perl-Time-Local                       noarch      1.2300-2.el7       base                         24 k
  perl-constant                          noarch      1.27-2.el7          base                         19 k
  perl-libs                                 x86_64      4:5.16.3-297.el7  base                        689 k
  perl-macros                            x86_64      4:5.16.3-297.el7  base                         44 k
  perl-parent                             noarch      1:0.225-244.el7   base                         12 k
  perl-podlators                         noarch      2.5.1-3.el7          base                       112 k
  perl-threads                            x86_64      1.87-4.el7          base                         49 k
  perl-threads-shared                  x86_64      1.43-6.el7          base                         39 k
Transaction Summary
============================================================
Install  3 Packages (+30 Dependent packages)

Total download size: 214 M
Is this ok [y/d/N]: y
Downloading packages:
경고: /var/cache/yum/x86_64/7/mysql57-community/packages/mysql-community-common-5.7.32-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEYs |    0 B  --:--:-- ETA
Public key for mysql-community-common-5.7.32-1.el7.x86_64.rpm is not installed
(1/33): mysql-community-common-5.7.32-1.el7.x86_64.rpm                 | 308 kB  00:00:00
(2/33): mysql-community-libs-5.7.32-1.el7.x86_64.rpm                        | 2.3 MB  00:00:00
(3/33): mysql-community-libs-compat-5.7.32-1.el7.x86_64.rpm             | 1.2 MB  00:00:00
(4/33): perl-Carp-1.26-244.el7.noarch.rpm                                       |  19 kB  00:00:01
(5/33): net-tools-2.0-0.25.20131004git.el7.x86_64.rpm                        | 306 kB  00:00:01
(6/33): perl-Encode-2.51-7.el7.x86_64.rpm                                       | 1.5 MB  00:00:00
(7/33): perl-File-Path-2.09-2.el7.noarch.rpm                                     |  26 kB  00:00:00
(8/33): perl-Exporter-5.68-3.el7.noarch.rpm                                      |  28 kB  00:00:00
(9/33): perl-File-Temp-0.23.01-3.el7.noarch.rpm                                |  56 kB  00:00:00
(10/33): perl-Getopt-Long-2.40-3.el7.noarch.rpm                               |  56 kB  00:00:00
(11/33): perl-HTTP-Tiny-0.033-3.el7.noarch.rpm                                 |  38 kB  00:00:00
(12/33): perl-PathTools-3.40-5.el7.x86_64.rpm                                   |  82 kB  00:00:00
(13/33): perl-Filter-1.49-3.el7.x86_64.rpm                                         |  76 kB  00:00:00
(14/33): perl-Pod-Escapes-1.04-297.el7.noarch.rpm                            |  52 kB  00:00:00
(15/33): perl-Pod-Simple-3.28-4.el7.noarch.rpm                                 | 216 kB  00:00:00
(16/33): perl-Pod-Usage-1.63-3.el7.noarch.rpm                                 |  27 kB  00:00:00
(17/33): perl-Scalar-List-Utils-1.27-248.el7.x86_64.rpm                         |  36 kB  00:00:00
(18/33): perl-Socket-2.010-5.el7.x86_64.rpm                                      |  49 kB  00:00:00
(19/33): perl-Storable-2.45-3.el7.x86_64.rpm                                     |  77 kB  00:00:00
(20/33): perl-Text-ParseWords-3.29-4.el7.noarch.rpm                          |  14 kB  00:00:00
(21/33): perl-Time-HiRes-1.9725-3.el7.x86_64.rpm                              |  45 kB  00:00:00
(22/33): perl-Time-Local-1.2300-2.el7.noarch.rpm                               |  24 kB  00:00:00
(23/33): perl-constant-1.27-2.el7.noarch.rpm                                     |  19 kB  00:00:00
(24/33): perl-libs-5.16.3-297.el7.x86_64.rpm                                      | 689 kB  00:00:00
(25/33): perl-Pod-Perldoc-3.20-4.el7.noarch.rpm                                |  87 kB  00:00:00
(26/33): perl-macros-5.16.3-297.el7.x86_64.rpm                                 |  44 kB  00:00:00
(27/33): perl-parent-0.225-244.el7.noarch.rpm                                   |  12 kB  00:00:00
(28/33): perl-podlators-2.5.1-3.el7.noarch.rpm                                   | 112 kB  00:00:00
(29/33): perl-threads-shared-1.43-6.el7.x86_64.rpm                             |  39 kB  00:00:00
(30/33): perl-threads-1.87-4.el7.x86_64.rpm                                      |  49 kB  00:00:00
(31/33): perl-5.16.3-297.el7.x86_64.rpm                                            | 8.0 MB  00:00:04
(32/33): mysql-community-client-5.7.32-1.el7.x86_64.rpm                     |  25 MB  00:00:09
(33/33): mysql-community-server-5.7.32-1.el7.x86_64.rpm                    | 173 MB  00:00:28
------------------------------------------------------------------------------------------------------
Total                                                                            7.0 MB/s | 214MB  00:00:30
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Importing GPG key 0x5072E1F5:
  Userid     : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
  Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
  Package    : mysql57-community-release-el7-11.noarch (installed)
  From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
  Installing : mysql-community-common-5.7.32-1.el7.x86_64                                 1/34
  Installing : mysql-community-libs-5.7.32-1.el7.x86_64                                        2/34
  Installing : mysql-community-client-5.7.32-1.el7.x86_64                                      3/34
  Installing : 1:perl-parent-0.225-244.el7.noarch                                                  4/34
  Installing : perl-HTTP-Tiny-0.033-3.el7.noarch                                                  5/34
  Installing : perl-podlators-2.5.1-3.el7.noarch                                                    6/34
  Installing : perl-Pod-Perldoc-3.20-4.el7.noarch                                                 7/34
  Installing : 1:perl-Pod-Escapes-1.04-297.el7.noarch                                           8/34
  Installing : perl-Text-ParseWords-3.29-4.el7.noarch                                           9/34
  Installing : perl-Encode-2.51-7.el7.x86_64                                                      10/34
  Installing : perl-Pod-Usage-1.63-3.el7.noarch                                                 11/34
  Installing : 4:perl-libs-5.16.3-297.el7.x86_64                                                   12/34
  Installing : perl-Storable-2.45-3.el7.x86_64                                                    13/34
  Installing : perl-Exporter-5.68-3.el7.noarch                                                    14/34
  Installing : perl-constant-1.27-2.el7.noarch                                                    15/34
  Installing : perl-Socket-2.010-5.el7.x86_64                                                     16/34
  Installing : perl-Time-Local-1.2300-2.el7.noarch                                              17/34
  Installing : perl-Carp-1.26-244.el7.noarch                                                      18/34
  Installing : perl-PathTools-3.40-5.el7.x86_64                                                  19/34
  Installing : perl-Scalar-List-Utils-1.27-248.el7.x86_64                                        20/34
  Installing : 1:perl-Pod-Simple-3.28-4.el7.noarch                                              21/34
  Installing : perl-File-Temp-0.23.01-3.el7.noarch                                               22/34
  Installing : perl-File-Path-2.09-2.el7.noarch                                                    23/34
  Installing : perl-threads-shared-1.43-6.el7.x86_64                                            24/34
  Installing : perl-threads-1.87-4.el7.x86_64                                                      25/34
  Installing : 4:perl-Time-HiRes-1.9725-3.el7.x86_64                                           26/34
  Installing : perl-Filter-1.49-3.el7.x86_64                                                         27/34
  Installing : 4:perl-macros-5.16.3-297.el7.x86_64                                               28/34
  Installing : perl-Getopt-Long-2.40-3.el7.noarch                                               29/34
  Installing : 4:perl-5.16.3-297.el7.x86_64                                                         30/34
  Installing : net-tools-2.0-0.25.20131004git.el7.x86_64                                       31/34
  Installing : mysql-community-server-5.7.32-1.el7.x86_64                                   32/34
  Installing : mysql-community-libs-compat-5.7.32-1.el7.x86_64                            33/34
  Erasing    : 1:mariadb-libs-5.5.65-1.el7.x86_64                                                34/34  
  Verifying  : perl-HTTP-Tiny-0.033-3.el7.noarch                                                 1/34  
  Verifying  : perl-threads-shared-1.43-6.el7.x86_64                                            2/34  
  Verifying  : perl-Storable-2.45-3.el7.x86_64                                                     3/34  
  Verifying  : 4:perl-libs-5.16.3-297.el7.x86_64                                                    4/34  
  Verifying  : perl-Exporter-5.68-3.el7.noarch                                                     5/34  
  Verifying  : perl-constant-1.27-2.el7.noarch                                                     6/34  
  Verifying  : perl-PathTools-3.40-5.el7.x86_64                                                   7/34  
  Verifying  : perl-Socket-2.010-5.el7.x86_64                                                      8/34  
  Verifying  : 1:perl-parent-0.225-244.el7.noarch                                                 9/34  
  Verifying  : perl-Pod-Usage-1.63-3.el7.noarch                                                10/34  
  Verifying  : 1:perl-Pod-Escapes-1.04-297.el7.noarch                                         11/34  
  Verifying  : perl-File-Temp-0.23.01-3.el7.noarch                                              12/34  
  Verifying  : net-tools-2.0-0.25.20131004git.el7.x86_64                                      13/34  
  Verifying  : 1:perl-Pod-Simple-3.28-4.el7.noarch                                             14/34  
  Verifying  : perl-Time-Local-1.2300-2.el7.noarch                                             15/34  
  Verifying  : perl-Text-ParseWords-3.29-4.el7.noarch                                        16/34  
  Verifying  : perl-Carp-1.26-244.el7.noarch                                                     17/34  
  Verifying  : mysql-community-client-5.7.32-1.el7.x86_64                                   18/34  
  Verifying  : mysql-community-libs-5.7.32-1.el7.x86_64                                      19/34  
  Verifying  : perl-Scalar-List-Utils-1.27-248.el7.x86_64                                       20/34  
  Verifying  : mysql-community-common-5.7.32-1.el7.x86_64                              21/34  
  Verifying  : perl-Encode-2.51-7.el7.x86_64                                                     22/34  
  Verifying  : perl-Pod-Perldoc-3.20-4.el7.noarch                                              23/34  
  Verifying  : perl-podlators-2.5.1-3.el7.noarch                                                 24/34  
  Verifying  : mysql-community-libs-compat-5.7.32-1.el7.x86_64                          25/34
  Verifying  : perl-File-Path-2.09-2.el7.noarch                                                   26/34  
  Verifying  : perl-threads-1.87-4.el7.x86_64                                                     27/34  
  Verifying  : 4:perl-Time-HiRes-1.9725-3.el7.x86_64                                          28/34  
  Verifying  : perl-Filter-1.49-3.el7.x86_64                                                        29/34  
  Verifying  : perl-Getopt-Long-2.40-3.el7.noarch                                              30/34  
  Verifying  : mysql-community-server-5.7.32-1.el7.x86_64                                  31/34  
  Verifying  : 4:perl-5.16.3-297.el7.x86_64                                                        32/34
  Verifying  : 4:perl-macros-5.16.3-297.el7.x86_64                                              33/34
  Verifying  : 1:mariadb-libs-5.5.65-1.el7.x86_64                                                34/34

Installed:
  mysql-community-libs.x86_64 0:5.7.32-1.el7
  mysql-community-libs-compat.x86_64 0:5.7.32-1.el7
  mysql-community-server.x86_64 0:5.7.32-1.el7

Dependency Installed:
  mysql-community-client.x86_64 0:5.7.32-1.el7
  mysql-community-common.x86_64 0:5.7.32-1.el7
  net-tools.x86_64 0:2.0-0.25.20131004git.el7
  perl.x86_64 4:5.16.3-297.el7
  perl-Carp.noarch 0:1.26-244.el7
  perl-Encode.x86_64 0:2.51-7.el7
  perl-Exporter.noarch 0:5.68-3.el7
  perl-File-Path.noarch 0:2.09-2.el7
  perl-File-Temp.noarch 0:0.23.01-3.el7
  perl-Filter.x86_64 0:1.49-3.el7
  perl-Getopt-Long.noarch 0:2.40-3.el7
  perl-HTTP-Tiny.noarch 0:0.033-3.el7
  perl-PathTools.x86_64 0:3.40-5.el7
  perl-Pod-Escapes.noarch 1:1.04-297.el7
  perl-Pod-Perldoc.noarch 0:3.20-4.el7
  perl-Pod-Simple.noarch 1:3.28-4.el7
  perl-Pod-Usage.noarch 0:1.63-3.el7
  perl-Scalar-List-Utils.x86_64 0:1.27-248.el7
  perl-Socket.x86_64 0:2.010-5.el7
  perl-Storable.x86_64 0:2.45-3.el7
  perl-Text-ParseWords.noarch 0:3.29-4.el7
  perl-Time-HiRes.x86_64 4:1.9725-3.el7
  perl-Time-Local.noarch 0:1.2300-2.el7
  perl-constant.noarch 0:1.27-2.el7
  perl-libs.x86_64 4:5.16.3-297.el7
  perl-macros.x86_64 4:5.16.3-297.el7
  perl-parent.noarch 1:0.225-244.el7
  perl-podlators.noarch 0:2.5.1-3.el7
  perl-threads.x86_64 0:1.87-4.el7
  perl-threads-shared.x86_64 0:1.43-6.el7

Replaced:
  mariadb-libs.x86_64 1:5.5.65-1.el7

Complete!

 

○ MySQL Server 시작

- MySQL Server 시작

$ sudo systemctl start mysqld.service

 

- MySQL Server 상태 확인

$ sudo systemctl status mysqld.service

● mysqld.service - MySQL Server
  Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
  Active: active (running) since 일 2020-11-22 18:05:41 KST; 3s ago
  Docs: man:mysqld(8)
          http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 1374 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
  Process: 1325 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
  Main PID: 1377 (mysqld)
  CGroup: /system.slice/mysqld.service
            └─1377 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid

 

○ MySQL Server 접속

- 초기 임시 비밀번호 확인

$ sudo grep 'temporary password' /var/log/mysqld.log

2020-11-22T06:49:44.933864Z 1 [Note] A temporary password is generated for root@localhost: Rw#dx=1h?y/h

 

- root 계정으로 MySQL Server 접속

$ mysql -u root -p

Enter password: Rw#dx=1h?y/h
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.32

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>

 

○ root 계정 비밀번호 설정

- root 계정 비밀번호 변경

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';

Query OK, 0 rows affected (0.00 sec)

※ 초기 임시 비밀번호를 변경하지 않으면 아래와 같은 ERROR 메세지가 나오기 때문에 비밀번호를 변경해줘야된다.

ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

 

○ root 계정 비밀번호 설정(단순 비밀번호로 변경하고자 할 경우)

- 비밀번호 유효성 설정 확인

mysql> SHOW VARIABLES LIKE 'validate_password%';

+-------------------------------------------+----------+
| Variable_name                                |  Value    |
+-------------------------------------------+----------+
| validate_password_check_user_name    |  OFF      |
| validate_password_dictionary_file         |             |
| validate_password_length                  |  8          |
| validate_password_mixed_case_count   |  1          |
| validate_password_number_count        |  1          |
| validate_password_policy                   | MEDIUM |
| validate_password_special_char_count   | 1          |
+-------------------------------------------+----------+
7 rows in set (0.01 sec)

 

- 비밀번호 유효성 정책을 낮음으로 변경

mysql> SET GLOBAL validate_password_policy=LOW;

Query OK, 0 rows affected (0.00 sec)

 

- 비밀번호 유효성 길이값을 6자리로 변경

mysql> SET GLOBAL validate_password_length = 6;

Query OK, 0 rows affected (0.00 sec)

 

- 비밀번호 유효성 설정 확인

mysql> SHOW VARIABLES LIKE 'validate_password%';

+-------------------------------------------+----------+
| Variable_name                                |  Value    |
+-------------------------------------------+----------+
| validate_password_check_user_name    |  OFF      |
| validate_password_dictionary_file         |             | 
| validate_password_length                  |  6          | 
| validate_password_mixed_case_count   |  1          | 
| validate_password_number_count        |  1          | 
| validate_password_policy                   | ROW      | 
| validate_password_special_char_count   | 1          |
+-------------------------------------------+----------+
7 rows in set (0.01 sec)

 

- root 계정 비밀번호 변경

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 's12345';

Query OK, 0 rows affected (0.00 sec)

 

○ root 계정 외부접속 허용

 

- root 계정 모든 권한 적용

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';

Query OK, 0 rows affected (0.00 sec)

 

- mysql 데이터베이스로 전환

mysql> use mysql;

Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

 

- 권한 적용 확인

mysql> select host, user from user;

+-----------+---------------+
| host        | user             |
+-----------+---------------+
| %           | root             |
| localhost  | mysql.session |
| localhost  | mysql.sys      |
| localhost  | root             |
+-----------+---------------+
4 rows in set (0.00 sec)

 

○ MySQL Port 변경

- my.cnf 파일에 변경하고자 하는 port 번호 작성

$ sudo vi /etc/my.cnf

port=13306

 

- seLinux 확인

$ sestatus

SELinux status: enabled
SELinuxfs mount: /sys/fs/selinux
SELinux root directory: /etc/selinux
Loaded policy name: targeted
Current mode: enforcing
Mode from config file: enforcing
Policy MLS status: enabled
Policy deny_unknown status: allowed
Max kernel policy version: 31

 

- 포트 확인

$ sudo semanage port -l | grep mysqld_port_t

mysqld_port_t tcp 1186, 3306, 63132-63164

 

- 포트 추가

$ sudo semanage port -a -t mysqld_port_t -p tcp 13306

 

- 포트 확인

$ sudo semanage port -l | grep mysqld_port_t

mysqld_port_t tcp 13306, 1186, 3306, 63132-63164

 

- MySQL Server 재시작

$ sudo systemctl restart mysqld.service

 

○ MySQL 방화벽 설정

- 방화벽 목록 조회

$ sudo filrewall-cmd --list-all

public (active)
  target: default
  icmp-block-inversion: no
  interfaces: ens33
  sources:
  services: dhcpv6-client ssh
  ports: 8080/tcp
  protocols:
  masquerade: no
  forward-ports:
  source-ports:
  icmp-blocks:
  rich rules:

 

- MySQL 서비스 허용 port 확인

$ sudo firewall-cmd --permanent --service=mysql --get-ports

3306/tcp

 

- MySQL 서비스의 기존 3306 port 제거

$ sudo firewall-cmd --permanent --service=mysql --remove-port=3306/tcp

success

 

- MySQL 서비스에 새로운 13306 port 추가

$ sudo firewall-cmd --permanent --service=mysql --add-port=13306/tcp

success

 

- 방화벽에  MySQL 서비스 항목 추가

$ sudo firewall-cmd --permanent --add-service=mysql

success

 

- 방화벽 재기동

$ sudo firewall-cmd --reload

success

 

- 방화벽 목록 조회

$ sudo firewall-cmd --list-all

public (active)
  target: default
  icmp-block-inversion: no
  interfaces: ens33
  sources:
  services: dhcpv6-client mysql ssh
  ports: 8080/tcp
  protocols:
  masquerade: no
  forward-ports:
  source-ports:
  icmp-blocks:
  rich rules: 

 

 

관련글 더보기