Kubernetes 이야기

MariaDB 설치 ( centos 7) 본문

Database/MariaDB

MariaDB 설치 ( centos 7)

kmaster 2022. 3. 22. 11:09
반응형

1. MariaDB Yum Repo 등록

 

# vi /etc/yum.repos.d/MariaDB.repo

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.7.3/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

 

2. Maria DB 설치

 

# yum install MariaDB -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
epel/x86_64/metalink                                                                                              | 9.8 kB  00:00:00
 * base: mirror.kakao.com
 * epel: ftp.iij.ad.jp
 * extras: mirror.kakao.com
 * updates: mirror.kakao.com
docker-ce-stable                                                                                                  | 3.5 kB  00:00:00
epel                                                                                                              | 4.7 kB  00:00:00
mariadb                                                                                                           | 3.4 kB  00:00:00
...
Replaced:
  mariadb-libs.x86_64 1:5.5.68-1.el7

Complete!

 

3. 설치 확인

 

#  mariadb --version
mariadb  Ver 15.1 Distrib 10.7.3-MariaDB, for Linux (x86_64) using readline 5.1

 

4. 실행 및 비밀번호 설정

 

// 서버 재기동 시 mariadb가 실행되도록 서정
# systemctl enable mariadb

//mariadb 실행
# systemctl start mariadb

//비밀번호 변경
# /usr/bin/mysqladmin -u root password '비밀번호'

 

5. mariadb utf8mb4 설정

 

# vi /etc/my.cnf

// 아래 내용 추가
[mysqld]
default_storage_engine=innodb

init-connect='SET NAMES utf8mb4'
lower_case_table_names=1
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci


[client]
port=3306
default-character-set = utf8mb4

[mysqldump]
default-character-set = utf8mb4

[mysql]
default-character-set = utf8mb4

 

설정 후 재기동

 

# systemctl restart mariadb

 

6. 변경된 CharacterSet 확인

 

# mysql -u root -p

Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 10.7.3-MariaDB MariaDB Server

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 variables like 'c%';
+----------------------------------+----------------------------+
| Variable_name                    | Value                      |
+----------------------------------+----------------------------+
| character_set_client             | utf8mb4                    |
| character_set_connection         | utf8mb4                    |
| character_set_database           | utf8mb4                    |
| character_set_filesystem         | binary                     |
| character_set_results            | utf8mb4                    |
| character_set_server             | utf8mb4                    |
| character_set_system             | utf8mb3                    |
| character_sets_dir               | /usr/share/mysql/charsets/ |
| check_constraint_checks          | ON                         |
| collation_connection             | utf8mb4_general_ci         |
| collation_database               | utf8mb4_unicode_ci         |
| collation_server                 | utf8mb4_unicode_ci         |
| column_compression_threshold     | 100                        |
| column_compression_zlib_level    | 6                          |
| column_compression_zlib_strategy | DEFAULT_STRATEGY           |
| column_compression_zlib_wrap     | OFF                        |
| completion_type                  | NO_CHAIN                   |
| concurrent_insert                | AUTO                       |
| connect_timeout                  | 10                         |
| core_file                        | OFF                        |
+----------------------------------+----------------------------+
20 rows in set (0.003 sec)

 

7. 기타 명령어

 

database 조회
MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| test               |
+--------------------+
5 rows in set (0.001 sec)

 

database 선택
MariaDB [(none)]> use test
Database changed

 

tables 목록
MariaDB [test]> show tables;
Empty set (0.000 sec)

 

table 생성
create table sample( 
    id int not null auto_increment, 
    name varchar(20),
    wdate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY ( id )
);

Query OK, 0 rows affected (0.006 sec)

 

사용자 추가/삭제
MariaDB [(none)]> create user 'kmaster8'@'%' identified by 'kmaster8';
MariaDB [(none)]> flush privileges;

 

delete from user where user='<username>'
flush privileges;

 

계정 패스워드 변경
update user set password=password('<password>') where user='root'

 

반응형
Comments