웹사이트 검색

RHEL/CentOS 8/7 및 Fedora 35에 MySQL 8.0을 설치하는 방법


MySQLGNU(일반 공중 라이선스)에 따라 출시된 오픈 소스 무료 관계형 데이터베이스 관리 시스템(RDBMS)입니다. . 생성된 각 데이터베이스에 대한 다중 사용자 액세스를 제공하여 단일 서버에서 여러 데이터베이스를 실행하는 데 사용됩니다.

이 문서에서는 RHEL/CentOS 8/7/6/에 최신 MySQL 8.0 버전을 설치하고 업데이트하는 과정을 안내합니다. Fedora는 YUM 유틸리티를 통해 MySQL Yum 저장소를 사용합니다.

1단계: MySQL Yum 리포지토리 추가

1. 최신 버전의 MySQL 서버, 클라이언트, MySQL 유틸리티, MySQL Workbench, 커넥터/를 설치하기 위한 RPM 패키지를 제공하는 공식 MySQL Yum 소프트웨어 저장소를 사용합니다. ODBC, RHEL/CentOS 8/7/6/Fedora 30-35용 커넥터/Python.

중요: 이 지침은 MySQL이 이미 있는 경우 서버에 MySQL을 새로 설치하는 경우에만 적용됩니다. > 타사 배포 RPM 패키지를 사용하여 설치한 경우 MySQL Yum Repository '를 사용하여 설치된 MySQL 패키지를 업그레이드하거나 교체하는 것이 좋습니다.

기존 MySQL 패키지를 업그레이드하거나 교체하기 전에 MySQL 데이터베이스 백업 가이드를 사용하여 중요한 데이터베이스 백업 및 구성 파일을 모두 가져가는 것을 잊지 마세요.

2. 이제 다음 MySQL Yum 저장소를 다운로드하고 각 Linux 배포 시스템의 저장소 목록에 추가하여 최신 버전의 MySQL(예: 8.0)을 설치합니다. 2018년 7월 27일에 출시됨).

--------------- On RHEL/CentOS 8 ---------------
wget https://repo.mysql.com/mysql80-community-release-el8-1.noarch.rpm
--------------- On RHEL/CentOS 7 ---------------
wget https://repo.mysql.com/mysql80-community-release-el7-1.noarch.rpm
--------------- On RHEL/CentOS 6 ---------------
wget https://dev.mysql.com/get/mysql80-community-release-el6-1.noarch.rpm
--------------- On Fedora 35 ---------------
wget https://dev.mysql.com/get/mysql80-community-release-fc35-1.noarch.rpm
--------------- On Fedora 34 ---------------
wget https://dev.mysql.com/get/mysql80-community-release-fc34-1.noarch.rpm
--------------- On Fedora 33 ---------------
wget https://dev.mysql.com/get/mysql80-community-release-fc33-1.noarch.rpm

3. Linux 플랫폼용 패키지를 다운로드한 후 이제 다음 명령을 사용하여 다운로드한 패키지를 설치합니다.

--------------- On RHEL/CentOS 8 ---------------
yum localinstall mysql80-community-release-el8-1.noarch.rpm
--------------- On RHEL/CentOS 7 ---------------
yum localinstall mysql80-community-release-el7-1.noarch.rpm
--------------- On RHEL/CentOS 6 ---------------
yum localinstall mysql80-community-release-el6-1.noarch.rpm
--------------- On Fedora 35 ---------------
dnf localinstall mysql80-community-release-fc35-1.noarch.rpm
--------------- On Fedora 34 ---------------
dnf localinstall mysql80-community-release-fc34-1.noarch.rpm
--------------- On Fedora 33 ---------------
yum localinstall mysql80-community-release-fc33-1.noarch.rpm

위의 설치 명령은 MySQL Yum 저장소를 시스템 저장소 목록에 추가하고 GnuPG 키를 다운로드하여 패키지의 무결성을 확인합니다.

4. 다음 명령을 사용하면 MySQL Yum 저장소가 성공적으로 추가되었는지 확인할 수 있습니다.

yum repolist enabled | grep "mysql.*-community.*"
dnf repolist enabled | grep "mysql.*-community.*"      [On Fedora versions]

2단계: 최신 MySQL 버전 설치

5. 다음 명령을 사용하여 최신 버전의 MySQL(현재 8.0)을 설치합니다.

yum install mysql-community-server
dnf install mysql-community-server      [On Fedora versions]

위 명령은 MySQL 서버 mysql-community-server, mysql-community-client, mysql-community-commonmysql-community-libs.

3단계: 다양한 MySQL 릴리스 버전 설치

6. MySQL 커뮤니티 서버의 다양한 하위 저장소를 사용하여 다양한 MySQL 버전을 설치할 수도 있습니다. 최신 MySQL 시리즈(현재 MySQL 8.0)의 하위 저장소는 기본적으로 활성화되며, 다른 모든 버전(예: MySQL 5.x 시리즈)의 하위 저장소는 기본적으로 비활성화됩니다. .

특정 하위 저장소에서 특정 버전을 설치하려면 yum-config-manager를 사용하여 --enable 또는 --disable 옵션을 사용할 수 있습니다. 또는 다음과 같이 dnf config-manager:

yum-config-manager --disable mysql57-community
yum-config-manager --enable mysql56-community
------------------ Fedora Versions ------------------
dnf config-manager --disable mysql57-community
dnf config-manager --enable mysql56-community

4단계: MySQL 서버 시작

7. MySQL을 성공적으로 설치한 후에는 다음 명령을 사용하여 MySQL 서버를 시작하고 활성화해야 합니다.

service mysqld start
systemctl enable mysqld.service

다음 명령을 사용하여 MySQL 서버의 상태를 확인할 수 있습니다.

systemctl status mysqld.service
OR
service mysqld status

이것은 CentOS 7 상자에서 MySQL을 실행하는 샘플 출력입니다.

Redirecting to /bin/systemctl status  mysqld.service
mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled)
   Active: active (running) since Thu 2015-10-29 05:15:19 EDT; 4min 5s ago
  Process: 5314 ExecStart=/usr/sbin/mysqld --daemonize $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
  Process: 5298 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 5317 (mysqld)
   CGroup: /system.slice/mysqld.service
           └─5317 /usr/sbin/mysqld --daemonize

Oct 29 05:15:19 localhost.localdomain systemd[1]: Started MySQL Server.

8. 이제 마지막으로 다음 명령을 사용하여 설치된 MySQL 버전을 확인합니다.

mysql --version

mysql  Ver 8.0.27 for Linux on x86_64 (MySQL Community Server - GPL)

5단계: MySQL 설치 보안

9. mysql_secure_installation 명령을 사용하면 루트 비밀번호 설정, 익명 사용자 제거, 루트 로그인 제거 등과 같은 중요한 설정을 수행하여 MySQL 설치를 보호할 수 있습니다.

참고: MySQL 버전 8.0 이상은 /var/log/mysqld.log에 임시 임의 비밀번호를 생성합니다. 설치 후.

MySQL 보안 명령을 실행하기 전에 아래 명령을 사용하여 비밀번호를 확인하세요.

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

비밀번호를 알고 나면 이제 다음 명령을 실행하여 MySQL 설치를 보호할 수 있습니다.

mysql_secure_installation

참고: 새 루트 비밀번호 입력은 /var/log/mysqld.log 파일의 임시 비밀번호를 의미합니다.

이제 화면 지침을 주의 깊게 따르십시오. 참조를 위해 아래 위 명령의 출력을 참조하십시오.

샘플 출력
Securing the MySQL server deployment.

Enter password for user root: Enter New Root Password

VALIDATE PASSWORD PLUGIN 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 plugin?

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: 2
Using existing password for root.

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

New password: Set New MySQL Password

Re-enter new password: Re-enter New MySQL Password

Estimated strength of the password: 100 
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! 

6단계: MySQL 서버에 연결

10. 사용자 이름과 비밀번호를 제공하여 새로 설치된 MySQL 서버에 연결합니다.

mysql -u root -p

샘플 출력:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.27 MySQL Community Server - GPL

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

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>

7단계: Yum으로 MySQL 업데이트

11. 새로 설치하는 것 외에도 다음 명령을 사용하여 MySQL 제품 및 구성 요소에 대한 업데이트를 수행할 수도 있습니다.

yum update mysql-server
dnf update mysql-server       [On Fedora versions]

MySQL에 대한 새 업데이트가 있으면 자동으로 설치됩니다. 그렇지 않은 경우 업데이트 대상으로 표시된 패키지가 없습니다라는 메시지가 표시됩니다.

이제 시스템에 MySQL 8.0이 성공적으로 설치되었습니다. 설치하는 데 문제가 있으면 언제든지 의견 섹션을 사용하여 해결 방법을 찾아보세요.