본문 바로가기

개발자이야기/마리아DB

centos 에 mariadb 설치

반응형
출처 : http://opennaru.tistory.com/104


RHEL 7 (Red Hat Enterprise Linux 7)에서 기본 데이터베이스가 MySQL 에서 MariaDB로 변경되었습니다. 
MariaDB는 대표적인 오픈 소스 데이터베이스로 알려진 MySQL에서 포크 한 MySQL 호환 데이터베이스 중의 하나로 오픈소스 RDBMS 입니다.
배포 라이센스는 GNU (General Public License) Version 2 입니다.
CentOS에서 RPM으로 배포되는 MariaDB를 설치하는 과정을 간단하게 정리하였습니다.


1. 동작환경

본 내용은 다음과 같은 환경을 전제로 작성되었습니다.
  • MariaDB 5.5.37
  • CentOS release 6.5 (Final)

2. MariaDB 설치

MariaDB를 위한 yum Repository 를 추가하기 위해 아래와 같이 "MariaDB.repo" 파일을 작성합니다.

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

"MariaDB.repo" 파일에 다음의 내용을 입력합니다.

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


yum을 이용하여 MariaDB-server와 MariaDB- client 를 설치합니다.

 yum install MariaDB-server MariaDB-client

설치된 MariaDB를 실행합니다.

  /etc/init.d/mysql start


3. root 패스워드와 외부 접속 설정

Mariadb root password 변경은 다음과 같이 진행합니다.

[admin@localhost ~]$ /usr/bin/mysql -u root mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.40-MariaDB MariaDB Server

Copyright (c) 2000, 2014, Oracle, Monty Program Ab and others.

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

MariaDB [mysql]> update user set password=password('opennaru') where user='root';
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4  Changed: 4  Warnings: 0

MariaDB [mysql]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [mysql]> quit
Bye 

MariaDB 재시작

  service mysql stop
  service mysql start


사용자 접속 정보 확인

[admin@localhost ~]$  /usr/bin/mysql -u root -p mysql
Enter password: 
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 5.5.40-MariaDB MariaDB Server

Copyright (c) 2000, 2014, Oracle, Monty Program Ab and others.

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

MariaDB [mysql]> select user,host,password from user;
+------+-----------------------+-------------------------------------------+
| user | host                  | password                                  |
+------+-----------------------+-------------------------------------------+
| root | localhost             | *889C926028E12783CDA5CF3FA3FAEDD7D98C2CB6 |
| root | localhost.localdomain | *889C926028E12783CDA5CF3FA3FAEDD7D98C2CB6 |
| root | 127.0.0.1             | *889C926028E12783CDA5CF3FA3FAEDD7D98C2CB6 |
| root | ::1                   | *889C926028E12783CDA5CF3FA3FAEDD7D98C2CB6 |
|      | localhost             |                                           |
|      | localhost.localdomain |                                           |
+------+-----------------------+-------------------------------------------+
6 rows in set (0.00 sec)


외부에서 root 로그인

MariaDB [mysql]> grant all privileges on *.* to 'root'@'192.%' identified by 'opennaru' with grant option;
Query OK, 0 rows affected (0.01 sec) 

  
4. 예제로 wordpress를 위한 데이터베이스 생성


[admin@localhost ~]$  /usr/bin/mysql -u root -p mysql
Enter password: 
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 5.5.40-MariaDB MariaDB Server

Copyright (c) 2000, 2014, Oracle, Monty Program Ab and others.

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

MariaDB [mysql]> create database wordpress character set utf8 collate utf8_bin; 
MariaDB [mysql]> CREATE USER 'wordpress'@'%' IDENTIFIED BY 'wordpress';
MariaDB [mysql]> grant all privileges on wordpress.* to 'wordpress'@'localhost' identified by 'wordpress' with grant option;
MariaDB [mysql]> flush privileges;




5. References


반응형

'개발자이야기 > 마리아DB' 카테고리의 다른 글

마리아DB 설치  (0) 2013.09.26