1. 대상환경
* 운영체제 : YUM을 지원하는 운영체제들( CentOS 5, CentOS 6, RHEL 5, RHEL 6, Fedora 16, Fedora 17) 및 32/64를 선택하는 방법을 기술했고, 그 중 CentOS 5.x, 32 Bit를 대상으로 가정했음
* MariaDB버전 : 선택하는 방법을 기술했고, 그냥 아무 이유없이, 현재 최신 버전인 10.1.2를 대상으로 함
2. 레포지토리 설정 및 YUM을 이용한 MariaDB 설치
/etc/yum.repo.d 디렉터리 하부에 레포지터리 정보 파일을 등록/세팅
*** 레포지토리 등록 및 설치를 위해 Super User권한이 필요하다.
# vi /etc/yum.repos.d/MariaDB.repo
[mariadb]
name=MariaDB
baseurl=http://yum.mariadb.org/5.5/centos6-amd64 # 주의:32비트라면 아래를 잘~ 읽어본다
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
위와 유사하게 입력해 주어야 하지만, 설치 대상 운영체제가 32비트? 또는, 64비트에 따라 Base URL이 상이함을 기억하도록 한다.
그래서, baseurl을 결정하기 위해, 다음 3단계의 절차를 밟도록 한다.
1. http://yum.mariadb.org/ 를 방문
==> 이 링크에서 자신이 설치하고자 하는 버전을 선택한다. 필자는 쭉~ 보고서, 2014년 12월7일 01시 19분에 등록된 10.1.2 버전을 설치하기로 결정했다.
2. http://yum.mariadb.org/10.1.2/ 로 방문
==> 운영체제 및 32비트/ 64비트를 선택한다. 필자는 필요에 의해 CentOS 5.x 32 bit를 선택해야 한다. 디렉터리를 살펴보니, centos5-x86이 대상이다.
3. http://yum.mariadb.org/10.1.2/centos5-x86/ 로 위의 baseurl을 선택했다.
따라서, 필자의 /etc/yum.repos.d/MariaDB.repo 파일은 다음이다.
[mariadb]
name=MariaDB
baseurl=http://yum.mariadb.org/10.1.2/centos5-x86/
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: ?????놀래지마세요????-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('비밀번호') 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 재시작
사용자 접속 정보 확인
[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: ?????놀래지마세요????-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 | *XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX |
| root | localhost.localdomain | *XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX |
| root | 127.0.0.1 | *XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX |
| root | ::1 | *XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX |
| | localhost | |
| | localhost.localdomain | |
+------+-----------------------+-------------------------------------------+
6 rows in set (0.00 sec)
외부에서 root 로그인 (별로 권고하지 않음)
MariaDB [mysql]> grant all privileges on *.* to 'root'@'192.%' identified by '비밀번호' with grant option;
Query OK, 0 rows affected (0.01 sec)
그외 간단한 명령들
* 데이터베이스명 testdb를 생성(utf8 환경)
MariaDB [mysql]> create database testdb character set utf8 collate utf8_bin;
데이터베이스 사용자 user01을 비밀번호 '비밀번호'로 생성
MariaDB [mysql]> CREATE USER 'user01'@'%' IDENTIFIED BY '비밀번호';
사용자id가 user01이고 비밀번호가 '비밀번호'인 사용자에게, 데이터베이스 testdb하에 존재할 모든 테이블(testdb.*)에 대해 대한 권한 부여
MariaDB [mysql]> grant all privileges on testdb.* to 'user01'@'localhost' identified by '비밀번호' with grant option;
MariaDB [mysql]> flush privileges;
참고 : https://mariadb.com/kb/en/mariadb/yum/