OS/Ubuntu

Ubuntu 24.04 MariaDB 설치 및 서비스 구동

강서버 2025. 3. 27. 17:09
728x90
반응형

MariaDB 설치

$ sudo apt install mariadb-server mariadb-client

 

[ 실행 로그 ]

gangserver@RC530-U:~$ sudo apt install mariadb-server mariadb-client
[sudo] gangserver 암호: 
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  galera-4 gawk libcgi-fast-perl libcgi-pm-perl libconfig-inifiles-perl
  libdbd-mysql-perl libdbi-perl libfcgi-bin libfcgi-perl libfcgi0t64
  libhtml-template-perl libmariadb3 libmysqlclient21 libsigsegv2
  libterm-readkey-perl liburing2 mariadb-client-core mariadb-common
  mariadb-plugin-provider-bzip2 mariadb-plugin-provider-lz4
  mariadb-plugin-provider-lzma mariadb-plugin-provider-lzo
  mariadb-plugin-provider-snappy mariadb-server-core mysql-common pv socat
Suggested packages:
  gawk-doc libmldbm-perl libnet-daemon-perl libsql-statement-perl
  libipc-sharedcache-perl mailx mariadb-test doc-base
The following NEW packages will be installed:
  galera-4 gawk libcgi-fast-perl libcgi-pm-perl libconfig-inifiles-perl
  libdbd-mysql-perl libdbi-perl libfcgi-bin libfcgi-perl libfcgi0t64
  libhtml-template-perl libmariadb3 libmysqlclient21 libsigsegv2
  libterm-readkey-perl liburing2 mariadb-client mariadb-client-core
  mariadb-common mariadb-plugin-provider-bzip2 mariadb-plugin-provider-lz4
  mariadb-plugin-provider-lzma mariadb-plugin-provider-lzo
  mariadb-plugin-provider-snappy mariadb-server mariadb-server-core
  mysql-common pv socat
0 upgraded, 29 newly installed, 0 to remove and 8 not upgraded.
Need to get 19.2 MB of archives.
After this operation, 198 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
(... 이하 로그 생략 ...)

 

 

설치 버전 확인

$ mariadb --version

 

[ 실행 로그 ]

gangserver@RC530-U:~$ mariadb --version
mariadb  Ver 15.1 Distrib 10.11.8-MariaDB, for debian-linux-gnu (x86_64) using  EditLine wrapper

 

 

부팅 시 MariaDB 서비스 시작 및 바로 MariaDB 서비스 구동

$ sudo systemctl enable --now mariadb

또는

$ sudo systemctl enable mariadb           <- 부팅 시 MariaDB 서비스 시작

$ sudo systemctl start mariadb               <- MariaDB 서비스 구동

 

[ 실행 로그 ]

gangserver@RC530-U:~$ sudo systemctl enable --now mariadb
Synchronizing state of mariadb.service with SysV service script with /usr/lib/systemd/systemd-sysv-install.
Executing: /usr/lib/systemd/systemd-sysv-install enable mariadb
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /usr/lib/systemd/system/mariadb.service.

 

gangserver@RC530-U:~$ sudo systemctl enable mariadb
Synchronizing state of mariadb.service with SysV service script with /usr/lib/systemd/systemd-sysv-install.
Executing: /usr/lib/systemd/systemd-sysv-install enable mariadb

 

gangserver@RC530-U:~$ sudo systemctl start mariadb
gangserver@RC530-U:~$ 

 

 

MariaDB 프로세스 확인

$ ps -ef | grep mysql

 

[ 실행 로그 ]

gangserver@RC530-U:~$ ps -ef | grep mysql
mysql      42589       1  0 17:03 ?        00:00:00 /usr/sbin/mariadbd
gangser+   42664   38992  0 17:04 pts/0    00:00:00 grep --color=auto mysql

 

 

초기 설정 (root 비번 설정 등)

$ sudo mysql_secure_installation


[ 실행 로그 ]

gangserver@RC530-U:~$ sudo 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):      <- 엔터 입력
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 authorisation.

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

Switch to unix_socket authentication [Y/n] n     <- unix_socket 인증으로 변경하려면 Y입력 (잘모르겠으면 n입력)
 ... skipping.

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

Change the root password? [Y/n] y                  <- root 비밀번호 변경하려면 Y입력
New password:                                                 <- 변경할 root 비밀번호 입력
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


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] n                  <- 익명 사용자 제거하려면 Y입력
 ... skipping.

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] n                <- 원격으로 root 로그인을 허용하지 않으려면 Y입력
 ... skipping.

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] n        <- 테스트 데이터베이스와 그것으로의 액세스를 제거하려 Y입력
 ... skipping.

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y     <- 지금 권한 테이블을 다시 로드하려면 Y입력
 ... 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 root 로그인 (위에서 변경한 root 비밀번호로 로그인)

$ mariadb -u root -p

 

[ 실행 로그 ]

gangserver@RC530-U:~$ mariadb -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 35
Server version: 10.11.8-MariaDB-0ubuntu0.24.04.1 Ubuntu 24.04

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)]> exit
Bye
gangserver@RC530-U:~$ 

 

728x90
반응형