LoginSignup
41
61

More than 5 years have passed since last update.

CentOS7 MariaDB(MySQL)インストール手順

Last updated at Posted at 2016-07-09

今更感はありますが、CentOS7へのMariaDBインストールの手順を記載します。
CentOS7からはMySQLに変わってMariaDBが標準になっています。
基本的にMySQLとの互換はありますので、MySQLのコマンドや、MySQLWorkbenchも使えます。

前提

  • CentOS7 インストール済み
  • SSHにて実行

手順

yumからインストール

yum install mariadb mariadb-server
rpm -qa | grep maria

文字コードの変更

vi /etc/my.cnf
my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# 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
character-set-server=utf8

[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

サービスの起動

systemctl enable mariadb.service
systemctl start mariadb.service

初期設定

基本的には全てそのままでインストールしても問題ないと思います。

mysql_secure_installation

データベース作成

create database testdb

ユーザー追加

mysql -u root -p
[パスワード]を入力

# データベースtestdbに対して全ての権限を持ったユーザtestuser@localhostを登録
grant all on testdb.* to testuser@localhost identified by 'password';
41
61
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
41
61