본문 바로가기

TroubleShooting/Linux

CentOS 7 에서 mariaDB 설치

728x90

CentOS 6 과는 아주 약간 달라진 CentOS 7 에서 mariaDB  설치 및 서비스 설정법


mariaDB 서버 설치

: "yum install mysql" 명령어로 해도 mariaDB 가 설치된다. 이젠 확실히 mariaDB 로 넘어간듯하다.


# yum install mariadb

Loading mirror speeds from cached hostfile

 * base: centos.mirror.cdnetworks.com

 * epel: epel.mirror.srv.co.ge

 * extras: centos.mirror.cdnetworks.com

 * updates: centos.mirror.cdnetworks.com

Resolving Dependencies

--> Running transaction check

---> Package mariadb-server.x86_64 1:5.5.40-2.el7_0 will be installed

--> Processing Dependency: mariadb(x86-64) = 1:5.5.40-2.el7_0 for package: 1:mariadb-server-5.5.40-2.el7_0.x86_64

--> Running transaction check

---> Package mariadb.x86_64 1:5.5.40-2.el7_0 will be installed

--> Finished Dependency Resolution


Dependencies Resolved


=================================================================================================================

 Package                      Arch                 Version                           Repository             Size

=================================================================================================================

Installing:

 mariadb-server               x86_64               1:5.5.40-2.el7_0                  updates                11 M

Installing for dependencies:

 mariadb                      x86_64               1:5.5.40-2.el7_0                  updates               8.9 M


Transaction Summary

=================================================================================================================

Install  1 Package (+1 Dependent package)


Total download size: 20 M

Installed size: 104 M

Is this ok [y/d/N]: y

Downloading packages:

(1/2): mariadb-server-5.5.40-2.el7_0.x86_64.rpm                                           |  11 MB  00:00:43     

(2/2): mariadb-5.5.40-2.el7_0.x86_64.rpm                                                  | 8.9 MB  00:00:45     

-----------------------------------------------------------------------------------------------------------------

Total                                                                            443 kB/s |  20 MB  00:00:45     

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

  Installing : 1:mariadb-5.5.40-2.el7_0.x86_64                                                               1/2 

  Installing : 1:mariadb-server-5.5.40-2.el7_0.x86_64                                                        2/2 

  Verifying  : 1:mariadb-server-5.5.40-2.el7_0.x86_64                                                        1/2 

  Verifying  : 1:mariadb-5.5.40-2.el7_0.x86_64                                                               2/2 


Installed:

  mariadb-server.x86_64 1:5.5.40-2.el7_0                                                                         


Dependency Installed:

  mariadb.x86_64 1:5.5.40-2.el7_0                                                                                


Complete!


서버가 설치가 안되었을 경우

: mariadb 클라이언트와 라이브러리만 설치되었을 경우, 서버 설치.

# yum install mariadb-server


서버 설정(server.cnf) 변경

: /etc/my.cnf 에다가 직접 설정을 해도 되지만, my.cnf.d/ 디렉토리를 활용하기로.

# cp /usr/share/mysql/my-medium.cnf /etc/my.cnf


UTF-8 설정

: /etc/my.cnf 에서 서버 설정부분에다가 추가.

[mysqld]

character-set-server=utf8
collation-server=utf8_general_ci


mariadb 서버 시작

: centOS 6 이하에서 service mysqld start/stop 명령이었는데, 변경된듯함.

# service mariadb start


root 패스워드 변경

# mysqladmin password

New password: 

Confirm new password:


DB 생성 및 사용자 추가

: 새로운 DB(test_db), 새로운 사용자(아이디 : db_user / 패스워드 : qwer1234), localhost, remote 호스트에서 연결할 수 있도록 설정.

MariaDB [(none)]> create database test_db;

Query OK, 1 row affected (0.05 sec)


MariaDB [(none)]> create user 'db_user'@'%' identified by 'qwer1234';

Query OK, 0 rows affected (0.00 sec)


MariaDB [(none)]> create user 'db_user'@'localhost' identified by 'qwer1234';

Query OK, 0 rows affected (0.00 sec)


MariaDB [(none)]> flush privileges;

Query OK, 0 rows affected (0.00 sec)


MariaDB [(none)]> grant all privileges on test_db.* to 'db_user'@'%';

Query OK, 0 rows affected (0.02 sec)


MariaDB [(none)]> grant all privileges on test_db.* to 'db_user'@'localhost';

Query OK, 0 rows affected (0.00 sec)


※ root 사용자를 외부에서 모든 DB 에 접근가능하게 하기 위해서는 다음 쿼리문을 실행

MariaDB [mysql]> grant all privileges on *.* to 'root'@'%' identified by 'qwer1234';


※ 위 내용을 다시 정리하자면 아래와 같다.

create user 'user명'@'%' identified by '패스워드';

create user 'user명'@'localhost' identified by '패스워드';

flush privileges;


create database DB명;

grant all privileges on DB명.* to 'user명'@'%';

grant all privileges on DB명.* to 'user명'@'localhost';


※ 부팅시 서비스 시작

 부팅하고 나서 자동으로 mariadb 가 실행되도록 서비스로 등록한다.

# systemctl enable mariadb.service

ln -s '/usr/lib/systemd/system/mariadb.service' '/etc/systemd/system/multi-user.target.wants/mariadb.service'


'TroubleShooting > Linux' 카테고리의 다른 글

방화벽 설정 on CentOS 7  (0) 2015.12.23
Ubuntu 에 bitnami Redmine 및 플러그인 설치하기  (0) 2015.04.20
CentOS 7 EPEL repository 설명  (0) 2014.11.24
openssl 1.0.1i 설치 on CentOS 6.5  (2) 2014.10.08
bash bug 확인  (0) 2014.09.29