CentOS 7에 MariaDB 설치하기
설치 및 셋팅 2015. 8. 20. 14:51
glibc 버전을 확인하고, 지원하는 마리아 버전을 받는다.
1 2 | $ getconf -a | grep libc GNU_LIBC_VERSION glibc 2.17 |
2.17를 지원하는 버전은 다음과 같다.
mariadb-10.0.21-linux-glibc_214-x86_64.tar.gz (requires GLIBC_2.14+)
받은 파일을 압축해제
1 | $ tar xzvf mariadb-10.0.21-linux-glibc_214-x86_64. tar .gz |
선택사항으로는 압축해제된 폴더를 간단히 접근하기 위해 심볼릭링크를 만든다.
1 | $ ln -s mariadb-10.0.21-linux-x86_64/ mysql |
/etc/my.cnf를 설정
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[mysqld] | |
## config server and data path | |
socket=/tmp/mysql.sock | |
basedir = /usr/local/mysql | |
datadir = /mysqldata/data | |
tmpdir = /mysqldata/tmp | |
log_bin = /mysqldata/binlog/bin | |
relay_log = /mysqldata/binlog/relay | |
innodb_data_home_dir = /mysqldata/data | |
innodb_log_group_home_dir = /mysqldata/iblog | |
## config character set | |
character_set_server = utf8 | |
collation_server = utf8_general_ci | |
## bin log | |
binlog_format = row | |
binlog_cache_size = 4M | |
## Replication related settings | |
server_id = 1 | |
expire_logs_days = 3 | |
log_slave_updates | |
# Disabling symbolic-links is recommended to prevent assorted security risks | |
symbolic-links=0 | |
# Settings user and group are ignored when systemd is used. | |
# If you need to run mysqld under a different user or group, | |
# customize your systemd unit file for mariadb according to the | |
# instructions in http://fedoraproject.org/wiki/Systemd | |
[mysqld_safe] | |
log-error=/mysqldata/mariadb.log | |
pid-file=/mysqldata/mariadb.pid | |
# | |
# include all files from the config directory | |
# | |
!includedir /etc/my.cnf.d | |
dba 그룹 추가
1 2 3 | $ groupadd -g 600 dba $ useradd -g 600 -u 605 mysql $ passwd mysql |
my.cnf에 설정한 각 폴더를 생성하고, 소유자 dba 설정
1 2 3 4 5 6 | $ mkdir -p /mysqldata/data $ mkdir -p /mysqldata/tmp $ mkdir -p /mysqldata/binlog/bin $ mkdir -p /mysqldata/binlog/relay $ mkdir -p /mysqldata/iblog $ chown -R mysql.dba /usr/local/mysql/ /mysqldata /etc/my .cnf |
1 2 | $ cd /usr/local/mysql $ . /scripts/mysql_install_db --user=mysql |
서비스에 등록하기
1 2 3 4 | $ cp support-files /mysql .server /etc/init .d /mysqld $ chkconfig --add /etc/init .d /mysqld $ chkconfig --level 2345 mysqld on $ service mysqld start |
루트 비번 세팅
1 | $ . /bin/mysqladmin -u root password 12121212 |
디비 접속
1 | $ . /bin/mysql -u root -p |
사용자 추가
1 2 3 4 | MariaDB [(none)]> use mysql mysql> CREATE USER 'your user name' @ '%' IDENTIFIED BY 'your password' ; mysql> GRANT ALL ON *.* TO 'your user name' @ '%' WITH GRANT OPTION; mysql> FLUSH PRIVILEGES; |