웹사이트 검색

Ubuntu 22.04에 최신 MariaDB 데이터베이스를 설치하는 방법


이 페이지에서

  1. 전제 조건
  2. MariaDB 저장소 추가
  3. MariaDB 설치 및 구성
  4. MariaDB 버전 확인\n
  5. 결론

MariaDB는 인기 있는 MySQL 데이터베이스 시스템의 포크인 무료 오픈 소스입니다. MySQL의 원래 개발자가 만든 널리 사용되는 관계형 데이터베이스 관리 시스템입니다. 확장성과 미션 크리티컬 배포를 위해 특별히 설계되었습니다. 기본적으로 MariaDB 패키지는 모든 주요 Linux 배포판의 기본 리포지토리에서 사용할 수 있습니다. 이 튜토리얼을 작성할 당시 MariaDB의 최신 버전은 10.8입니다. 모든 주요 릴리스는 최소 5년 동안 유지됩니다. 따라서 MariaDB 10.8.0은 2027년까지 지원됩니다.

이 튜토리얼에서는 Ubuntu 22.04 서버에 MariaDB 10.8을 설치하는 방법을 보여줍니다.

전제 조건

  • Ubuntu 22.04를 실행하는 서버.\n
  • 루트 암호는 서버에서 구성됩니다.\n

MariaDB 리포지토리 추가

기본적으로 최신 버전의 MariaDB는 Ubuntu 22.04 표준 리포지토리에서 사용할 수 없습니다. 따라서 시스템에 MariaDB 공식 리포지토리를 추가해야 합니다.

먼저 다음 명령을 사용하여 필요한 모든 종속 항목을 설치합니다.

apt-get install software-properties-common gnupg2 -y

모든 종속성이 설치되면 다음 명령을 사용하여 MariaDB 서명 키를 가져옵니다.

apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'

다음 출력이 표시되어야 합니다.

Executing: /tmp/apt-key-gpghome.kGFC5Ag1H8/gpg.1.sh --fetch-keys https://mariadb.org/mariadb_release_signing_key.asc
gpg: requesting key from 'https://mariadb.org/mariadb_release_signing_key.asc'
gpg: key F1656F24C74CD1D8: public key "MariaDB Signing Key <>" imported
gpg: Total number processed: 1
gpg:               imported: 1

다음으로 다음 명령을 사용하여 MariaDB 리포지토리를 추가합니다.

add-apt-repository 'deb [arch=amd64] http://mariadb.mirror.globo.tech/repo/10.8/ubuntu jammy main'

리포지토리가 추가되면 다음 명령을 사용하여 리포지토리를 업데이트합니다.

apt-get update -y

이 시점에서 MariaDB 리포지토리가 추가되고 최신 상태가 됩니다. 이제 다음 단계로 진행할 수 있습니다.

MariaDB 설치 및 구성

이제 다음 명령을 사용하여 최신 버전의 MariaDB 서버 및 클라이언트를 설치합니다.

apt-get install mariadb-server mariadb-client -y

성공적으로 설치한 후 MariaDB 서비스를 시작하고 시스템 재부팅 시 시작되도록 활성화합니다.

systemctl start mariadb
systemctl enable mariadb

다음으로 MariaDB 설치를 보호하고 MariaDB 루트 암호를 설정해야 합니다. 다음 스크립트를 실행하여 수행할 수 있습니다.

mysql_secure_installation

아래와 같이 현재 루트 암호를 제공하라는 메시지가 표시됩니다.

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): 

Enter 키를 누르십시오. 아래와 같이 unix_socket 인증으로 전환하라는 메시지가 표시됩니다.

OK, successfully used password, moving on...

Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorization.

You already have your root account protected, so you can safely answer 'n'.

Switch to unix_socket authentication [Y/n] Y

Y를 입력하고 Enter 키를 누릅니다. 아래와 같이 루트 암호를 변경하라는 메시지가 표시됩니다.

Enabled successfully!
Reloading privilege tables..
 ... Success!


You already have your root account protected, so you can safely answer 'n'.

Change the root password? [Y/n] Y

Y를 입력하고 Enter 키를 눌러 루트 암호를 변경합니다.

New password: 
Re-enter new password: 

보안 암호를 입력하고 Enter 키를 누르십시오. 다음 출력이 표시되어야 합니다.

Password updated successfully!
Reloading privilege tables..
 ... Success!


Next, you will be asked to remove anonymous users as shown below:

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

Y를 입력하고 Enter 키를 눌러 익명 사용자를 제거합니다. 아래와 같이 원격 루트 로그인을 허용하지 않겠다는 메시지가 표시됩니다.

 ... 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? [Y/n] Y

Y를 입력하고 Enter 키를 누릅니다. 아래와 같이 테스트 데이터베이스를 제거하라는 메시지가 표시됩니다.

 ... Success!

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

Y를 입력하고 Enter 키를 눌러 테스트 데이터베이스를 제거합니다. 아래와 같이 권한 테이블을 다시 로드하라는 메시지가 표시됩니다.

 - 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? [Y/n] Y

Y를 입력하고 Enter 키를 누르면 다음과 같은 결과가 표시됩니다.

 ... 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!

MariaDB 버전 확인

이 시점에서 MariaDB가 설치되고 보호됩니다. 다음으로 설치된 MariaDB 버전을 확인해야 합니다.

먼저 다음 명령을 사용하여 MariaDB 셸에 로그인합니다.

mysql -u root -p

MariaDB 루트 비밀번호를 제공하고 Enter를 누르십시오. 로그인하면 다음 출력이 표시됩니다.

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 31
Server version: 10.8.3-MariaDB-1:10.8.3+maria~jammy mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> 

다음 명령을 실행하여 MariaDB 버전을 확인합니다.

MariaDB [(none)]> SELECT VERSION();

다음 출력이 표시되어야 합니다.

+-------------------------------------+
| VERSION()                           |
+-------------------------------------+
| 10.8.3-MariaDB-1:10.8.3+maria~jammy |
+-------------------------------------+
1 row in set (0.000 sec)

결론

이번 포스트에서는 Ubuntu 22.04 서버에 최신 MariaDB 데이터베이스를 설치하는 방법에 대해 설명했습니다. 또한 MariaDB를 보호하고 MariaDB 버전을 확인하는 방법도 설명했습니다. 이제 MariaDB에 연결하고 데이터베이스, 사용자 생성을 시작하고 이를 애플리케이션과 통합할 수 있습니다.