본문 바로가기
+ DataBase/MySQL(MariaDB)

[MySQL] CentOS 8 Mysql Install 하기

by :: Teacher :: 2020. 6. 13.
728x90
반응형

CentOS 8 시스템에 Mysql을 설치해보도록 하자. 

1. yum 명령어를 통해 "mysql-server" 설치

[root@localhost ~]$ yum install mysql-server
CentOS-8 - AppStream                                                  8.4 kB/s | 4.3 kB     00:00
CentOS-8 - Base                                                       7.3 kB/s | 3.9 kB     00:00
CentOS-8 - Extras                                                     2.5 kB/s | 1.5 kB     00:00
Dependencies resolved.
======================================================================================================
 Package                       Arch      Version                                   Repository    Size
======================================================================================================
Installing:
 mysql-server                  x86_64    8.0.17-3.module_el8.0.0+181+899d6349      AppStream     22 M
Installing dependencies:
 mariadb-connector-c-config    noarch    3.0.7-1.el8                               AppStream     13 k
 mecab                         x86_64    0.996-1.module_el8.0.0+41+ca30bab6.9      AppStream    397 k
 mysql                         x86_64    8.0.17-3.module_el8.0.0+181+899d6349      AppStream     11 M
 mysql-common                  x86_64    8.0.17-3.module_el8.0.0+181+899d6349      AppStream    143 k
 mysql-errmsg                  x86_64    8.0.17-3.module_el8.0.0+181+899d6349      AppStream    557 k
 protobuf-lite                 x86_64    3.5.0-7.el8                               AppStream    150 k
Enabling module streams:
 mysql                                   8.0

Transaction Summary
======================================================================================================
설치  7 Packages

Total download size: 33 M
Installed size: 216 M
Is this ok [y/N]: y
패키지 다운로드중:
(1/7): mariadb-connector-c-config-3.0.7-1.el8.noarch.rpm              604 kB/s |  13 kB     00:00
(2/7): mysql-common-8.0.17-3.module_el8.0.0+181+899d6349.x86_64.rpm   2.3 MB/s | 143 kB     00:00
(3/7): mecab-0.996-1.module_el8.0.0+41+ca30bab6.9.x86_64.rpm          3.2 MB/s | 397 kB     00:00
(4/7): mysql-errmsg-8.0.17-3.module_el8.0.0+181+899d6349.x86_64.rpm   4.2 MB/s | 557 kB     00:00
(5/7): protobuf-lite-3.5.0-7.el8.x86_64.rpm                           3.1 MB/s | 150 kB     00:00
(6/7): mysql-8.0.17-3.module_el8.0.0+181+899d6349.x86_64.rpm          3.5 MB/s |  11 MB     00:03
(7/7): mysql-server-8.0.17-3.module_el8.0.0+181+899d6349.x86_64.rpm   6.0 MB/s |  22 MB     00:03
------------------------------------------------------------------------------------------------------
합계                                                                  8.2 MB/s |  33 MB     00:04
트랜잭션 점검 실행 중
트랜잭션 검사가 성공했습니다.
트랜잭션 테스트 실행 중
트랜잭션 테스트가 완료되었습니다.
거래 실행 중
  준비 중입니다  :                                                                                1/1
  Installing     : mariadb-connector-c-config-3.0.7-1.el8.noarch                                  1/7
  Installing     : mysql-common-8.0.17-3.module_el8.0.0+181+899d6349.x86_64                       2/7
  Installing     : mysql-8.0.17-3.module_el8.0.0+181+899d6349.x86_64                              3/7
  Installing     : mysql-errmsg-8.0.17-3.module_el8.0.0+181+899d6349.x86_64                       4/7
  Installing     : protobuf-lite-3.5.0-7.el8.x86_64                                               5/7
  Installing     : mecab-0.996-1.module_el8.0.0+41+ca30bab6.9.x86_64                              6/7
  스크립틀릿 실행: mecab-0.996-1.module_el8.0.0+41+ca30bab6.9.x86_64                              6/7
  스크립틀릿 실행: mysql-server-8.0.17-3.module_el8.0.0+181+899d6349.x86_64                       7/7
  Installing     : mysql-server-8.0.17-3.module_el8.0.0+181+899d6349.x86_64                       7/7
  스크립틀릿 실행: mysql-server-8.0.17-3.module_el8.0.0+181+899d6349.x86_64                       7/7
ValueError: 에 대한 파일 컨텍스트 /var/log/mysql(/.*)? 이미 정의 된

  확인 중        : mariadb-connector-c-config-3.0.7-1.el8.noarch                                  1/7
  확인 중        : mecab-0.996-1.module_el8.0.0+41+ca30bab6.9.x86_64                              2/7
  확인 중        : mysql-8.0.17-3.module_el8.0.0+181+899d6349.x86_64                              3/7
  확인 중        : mysql-common-8.0.17-3.module_el8.0.0+181+899d6349.x86_64                       4/7
  확인 중        : mysql-errmsg-8.0.17-3.module_el8.0.0+181+899d6349.x86_64                       5/7
  확인 중        : mysql-server-8.0.17-3.module_el8.0.0+181+899d6349.x86_64                       6/7
  확인 중        : protobuf-lite-3.5.0-7.el8.x86_64                                               7/7

설치됨:
  mysql-server-8.0.17-3.module_el8.0.0+181+899d6349.x86_64
  mariadb-connector-c-config-3.0.7-1.el8.noarch
  mecab-0.996-1.module_el8.0.0+41+ca30bab6.9.x86_64
  mysql-8.0.17-3.module_el8.0.0+181+899d6349.x86_64
  mysql-common-8.0.17-3.module_el8.0.0+181+899d6349.x86_64
  mysql-errmsg-8.0.17-3.module_el8.0.0+181+899d6349.x86_64
  protobuf-lite-3.5.0-7.el8.x86_64

완료되었습니다!

2. mysql 서비스 최초 구동 및 구동 확인 

[root@localhost ~]$ systemctl start mysqld.service
[root@localhost ~]$ systemctl status mysqld
● mysqld.service - MySQL 8.0 database server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled; vendor preset: disabled)
   Active: active (running) since Fri 2020-06-12 13:07:54 EDT; 16s ago
  Process: 7229 ExecStartPost=/usr/libexec/mysql-check-upgrade (code=exited, status=0/SUCCESS)
  Process: 7103 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mysqld.service (code=exited, status=0/>
  Process: 7078 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
 Main PID: 7187 (mysqld)
   Status: "Server is operational"
    Tasks: 39 (limit: 23752)
   Memory: 532.6M
   CGroup: /system.slice/mysqld.service
           └─7187 /usr/libexec/mysqld --basedir=/usr

 6월 12 13:07:23 localhost.localdomain systemd[1]: Starting MySQL 8.0 database server...
 6월 12 13:07:24 localhost.localdomain mysql-prepare-db-dir[7103]: Initializing MySQL database
 6월 12 13:07:54 localhost.localdomain systemd[1]: Started MySQL 8.0 database server.

3. 서버 재구동시 mysql 자동 서비스 구동 설정

[root@localhost ~]$ systemctl enable mysqld
Created symlink /etc/systemd/system/multi-user.target.wants/mysqld.service → /usr/lib/systemd/system/mysqld.service.

# 비활성화를 하고 싶은경우
$ systemctl disable mysqld

4. mysql_secure_installation 설정

[root@localhost ~]$ mysql_secure_installation

Securing the MySQL server deployment.

VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?

Press y|Y for Yes, any other key for No: y

There are three levels of password validation policy:

LOW    Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary                  file

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0
Using existing password for root.

Estimated strength of the password: 0
Change the password for root ? ((Press y|Y for Yes, any other key for No) : y

New password:

Re-enter new password:

Estimated strength of the password: 50
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
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!

5. Mysql 설치 Version 확인

[root@localhost ~]$ mysqladmin -u root -p version
Enter password:
mysqladmin  Ver 8.0.17 for Linux on x86_64 (Source distribution)
Copyright (c) 2000, 2019, 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.

Server version		8.0.17
Protocol version	10
Connection		Localhost via UNIX socket
UNIX socket		/var/lib/mysql/mysql.sock
Uptime:			10 min 12 sec

Threads: 2  Questions: 26  Slow queries: 0  Opens: 155  Flush tables: 3  Open tables: 72  Queries per second avg: 0.042

6. Mysql 접속 확인

[root@localhost ~]$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 33
Server version: 8.0.17 Source distribution

Copyright (c) 2000, 2019, 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>

728x90
반응형

댓글


loading