LoginSignup
1
1

More than 5 years have passed since last update.

【俺メモ】CentOS7にMariaDBのインストールまで(そのあとNode.jsや)

Last updated at Posted at 2016-05-11

っていうか、なんかわからんけど、Node.jsでSqlite3使うパッケージが上手く動かんから、MariaDBに移行や。
(大したもん作ってるわけでもないんやけどなぁ。)

※文字化け対策が甘かったから修正したわ。(5/12)
server.confに"skip-character-set-client-handshake"が無いとNode.jsから呼んだ時に文字化けしたし。

インストール

yumリポジトリファイル追加

まずは、yumでインストール出来るようにリポジトリファイルの作成や。
とりあえず、現時点の最新安定版の10.1系を入れるで。

cmd
$ sudo touch /etc/yum.repos.d/MariaDB.repo
$ echo '[mariadb]' | sudo tee -a /etc/yum.repos.d/MariaDB.repo
$ echo 'name = MariaDB' | sudo tee -a /etc/yum.repos.d/MariaDB.repo
$ echo 'baseurl = http://yum.mariadb.org/10.1/centos7-amd64' | sudo tee -a /etc/yum.repos.d/MariaDB.repo
$ echo 'gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB' | sudo tee -a /etc/yum.repos.d/MariaDB.repo
$ echo 'gpgcheck=1' | sudo tee -a /etc/yum.repos.d/MariaDB.repo

MariaDBインストール

んで、インストールな。

cmd
$ sudo yum install MariaDB-server MariaDB-client -y

Galera Clusterをインストールする場合はこっちやで。

cmd
$ sudo yum install MariaDB-Galera-server MariaDB-client galera -y 

日本語対応設定

起動前に設定ファイルに追記してUTF8をデフォで使用できるようにするで。

cmd
$ echo '' | sudo tee -a /usr/share/mysql/my-small.cnf
$ echo '[client]' | sudo tee -a /usr/share/mysql/my-small.cnf
$ echo 'default-character-set = utf8' | sudo tee -a /usr/share/mysql/my-small.cnf
$ echo '' | sudo tee -a /usr/share/mysql/my-small.cnf
$ echo '[mysqld]' | sudo tee -a /usr/share/mysql/my-small.cnf
$ echo 'character-set-server = utf8' | sudo tee -a /usr/share/mysql/my-small.cnf
$ echo 'skip-character-set-client-handshake' | sudo tee -a /usr/share/mysql/my-small.cnf

MariaDB起動

設定ファイルをコピーして起動や。

cmd
$ sudo cp -p /usr/share/mysql/my-small.cnf /etc/my.cnf.d/server.cnf
$ sudo systemctl enable mariadb
$ sudo systemctl start mariadb

初期設定

対話式の初期設定やで。
まずはコマンドで設定開始や。

cmd
$ sudo /usr/bin/mysql_secure_installation
...

続いて、問いに答えるで。

cmd
Enter current password for root (enter for none): {空Enter}
...

Set root password? [Y/n] Y
New password: {パスワード}
Re-enter new password: {パスワード}
...

Remove anonymous users? [Y/n] Y
... Success!

Disallow root login remotely? [Y/n] Y
... Success!

Remove test database and access to it? [Y/n] Y
 - Dropping test database...
... Success!
 - Removing privileges on test database...
... Success!

Reload privilege tables now? [Y/n] Y
... Success!

...
Thanks for using MariaDB!

で設定完了な。

Vagrantでプロビジョニング

今回、インストールに使用したコマンドをVagrantfileにそのまま張り付ければ使えるで。

1
1
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
1
1