OS/Linux
Ubuntu : mariadb-server 설치
파란크리스마스
2025. 4. 24. 21:36
728x90
출처
키 다운로드
user01@css:~$ sudo apt-get install apt-transport-https curl
user01@css:~$ sudo mkdir -p /etc/apt/keyrings
user01@css:~$ sudo curl -o /etc/apt/keyrings/mariadb-keyring.pgp 'https://mariadb.org/mariadb_release_signing_key.pgp'
mariadb 소스 추가
user01@css:~$ sudo vi /etc/apt/sources.list.d/mariadb.sources
# MariaDB 11.8 repository list - created 2025-04-14 00:00 UTC
# https://mariadb.org/download/
X-Repolib-Name: MariaDB
Types: deb
# deb.mariadb.org is a dynamic mirror if your preferred mirror goes offline. See https://mariadb.org/mirrorbits/ for details.
# URIs: https://deb.mariadb.org/11.rc/ubuntu
URIs: https://tw1.mirror.blendbyte.net/mariadb/repo/11.8/ubuntu
Suites: noble
Components: main main/debug
Signed-By: /etc/apt/keyrings/mariadb-keyring.pgp
mariadb 설치
user01@css:~$ sudo apt-get update
user01@css:~$ sudo apt install mariadb-server
mariadb 서비스 등록 확인
user01@css:~$ sudo systemctl is-enabled mariadb
enabled
mariadb 서비스 실행 상태 확인
user01@css:~$ sudo systemctl status mysql
● mariadb.service - MariaDB 11.8.1 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; preset: enabled)
Drop-In: /etc/systemd/system/mariadb.service.d
└─migrated-from-my.cnf-settings.conf
Active: active (running) since Thu 2025-04-24 12:33:14 UTC; 53min ago
Docs: man:mariadbd(8)
https://mariadb.com/kb/en/library/systemd/
Process: 5020 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCE>
Process: 5022 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= || VAR=`/usr/bin/galera_recovery`>
Process: 5106 ExecStartPost=/bin/rm -f /run/mysqld/wsrep-start-position (code=exited, status=0/SUCCESS)
Process: 5108 ExecStartPost=/etc/mysql/debian-start (code=exited, status=0/SUCCESS)
Main PID: 5050 (mariadbd)
Status: "Taking your SQL requests now..."
Tasks: 9 (limit: 29494)
Memory: 174.1M (peak: 263.6M)
CPU: 7.101s
CGroup: /system.slice/mariadb.service
└─5050 /usr/sbin/mariadbd
Apr 24 12:33:12 css mariadbd[5050]: 2025-04-24 12:33:12 0 [Note] InnoDB: log sequence number 47629; transaction id 14
Apr 24 12:33:12 css mariadbd[5050]: 2025-04-24 12:33:12 0 [Note] Plugin 'FEEDBACK' is disabled.
Apr 24 12:33:12 css mariadbd[5050]: 2025-04-24 12:33:12 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_>
Apr 24 12:33:12 css mariadbd[5050]: 2025-04-24 12:33:12 0 [Note] Plugin 'wsrep-provider' is disabled.
Apr 24 12:33:12 css mariadbd[5050]: 2025-04-24 12:33:12 0 [Note] InnoDB: Buffer pool(s) load completed at 250424 12:33:>
Apr 24 12:33:14 css mariadbd[5050]: 2025-04-24 12:33:14 0 [Note] Server socket created on IP: '127.0.0.1'.
Apr 24 12:33:14 css mariadbd[5050]: 2025-04-24 12:33:14 0 [Note] mariadbd: Event Scheduler: Loaded 0 events
Apr 24 12:33:14 css mariadbd[5050]: 2025-04-24 12:33:14 0 [Note] /usr/sbin/mariadbd: ready for connections.
Apr 24 12:33:14 css mariadbd[5050]: Version: '11.8.1-MariaDB-ubu2404' socket: '/run/mysqld/mysqld.sock' port: 3306 m>
Apr 24 12:33:14 css systemd[1]: Started mariadb.service - MariaDB 11.8.1 database server.
mariadb root 패스워드 변경
user01@css:~$ sudo /usr/bin/mysqladmin -u root password
/usr/bin/mysqladmin: Deprecated program name. It will be removed in a future release, use '/usr/bin/mariadb-admin' instead
New password:
Confirm new password:
mariadb 접속
user01@css:~$ mysql -u root -p
mysql: Deprecated program name. It will be removed in a future release, use '/usr/bin/mariadb' instead
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 34
Server version: 11.8.1-MariaDB-ubu2404 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)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.001 sec)
MariaDB [(none)]>
mariadb DB 사용자 생성
user01@css:~$ mysql -u root -p
mysql: Deprecated program name. It will be removed in a future release, use '/usr/bin/mariadb' instead
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 35
Server version: 11.8.1-MariaDB-ubu2404 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)]> CREATE DATABASE bluexmas_db CHARACTER SET utf8mb4 collate utf8mb4_general_ci;
Query OK, 1 row affected (0.000 sec)
MariaDB [(none)]> create user 'user01'@'localhost' identified by 'passwd';
Query OK, 0 rows affected (0.003 sec)
MariaDB [(none)]> grant all privileges on *.* to 'user01'@'localhost' with grant option;
Query OK, 0 rows affected (0.008 sec)
MariaDB [(none)]> create user 'user01'@'%' identified by 'passwd';
Query OK, 0 rows affected (0.003 sec)
MariaDB [(none)]> grant all privileges on bluexmas_db.* to 'user01'@'%' with grant option;
Query OK, 0 rows affected (0.003 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> exit
Bye
mariadb 포트 개발
user01@css:~$ sudo ufw status verbose
[sudo] password for user01:
Status: inactive
user01@css:~$ sudo ufw enable
Command may disrupt existing ssh connections. Proceed with operation (y|n)? y
Firewall is active and enabled on system startup
user01@css:~$ sudo ufw status verbose
Status: active
Logging: on (low)
Default: deny (incoming), allow (outgoing), deny (routed)
New profiles: skip
user01@css:~$ sudo ufw allow 22
Rule added
Rule added (v6)
user01@css:~$ sudo ufw allow 3306
Rule added
Rule added (v6)
user01@css:~$ sudo ufw status verbose
Status: active
Logging: on (low)
Default: deny (incoming), allow (outgoing), deny (routed)
New profiles: skip
To Action From
-- ------ ----
22 ALLOW IN Anywhere
3306 ALLOW IN Anywhere
22 (v6) ALLOW IN Anywhere (v6)
3306 (v6) ALLOW IN Anywhere (v6)
user01@css:~$
mariadb 외부 접속 허용
mariadb 포트 확인
mariadb 포트 확인 해보면 127.0.0.1:3306 로컬에서 접속하도록 설정 되어 있는 것을 확인 할 수 있음
user01@css:~$ netstat -nao | grep 3306
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN off (0.00/0/0)
mariadb 환경 변수 수정
user01@css:~$ sudo vi /etc/mysql/mariadb.conf.d/50-server.cnf
bind-address 주석 처리
[mariadbd]
# bind-address = 127.0.0.1
# skip-ssl # (ERROR 2026 (HY000)) 해결
mariadb 서비스 재시작
user01@css:~$ sudo systemctl restart mysql
mariadb 포트 확인
user01@css:~$ netstat -nao | grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN off (0.00/0/0)
tcp6 0 0 :::3306 :::* LISTEN off (0.00/0/0)
728x90