LoginSignup
4
2

More than 3 years have passed since last update.

各LinuxディストリビューションにおけるMariaDB

Last updated at Posted at 2018-04-29

ここ数年でほとんどのLinuxディストリビューションで MySQL から MariaDB への移行が進んでいます。

https://mariadb.com/kb/en/library/mariadb-package-repository-setup-and-usage/ に記載されているように、

curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash

でレポジトリ設定を行えば、最新版GAがインストールできますが、業務で利用すると思われる各ディストリビューションの標準レポジトリでインストール可能な MariaDB のバージョン、インストールコマンド、service起動法を確認してみました。

Distribution MariaDB / MySQL version installation start service 備考
CentOS 6 MySQL 5.1 yum -y install mysql-server sevice mysqld start
CentOS 7 MariaDB 5.5 yum -y install mariadb-server systemctl start mariadb
Debian 8 (jessie) MariaDB 10.0 apt -y install mariadb-server systemctl start mysql
Debian 9 (stretch) MariaDB 10.1 apt -y install mysql-server / apt -y install mariadb-server systemctl start mysql / systemctl start mariadb mysql aliased to mariadb
Ubuntu 16.04 LTS MariaDB 10.0 apt -y install mariadb-server systemctl start mysql
Ubuntu 18.04 LTS MariaDB 10.1 apt -y install mariadb-server systemctl start mysql / systemctl start mysqld / systemctl start mariadb
SLES 12 SP2 MariaDB 10.0 zypper -n install mariadb systemctl start mysql

ディストリビューションによって、パッケージ名やservice名が異なったり、aliasになっている場合がありますが、最近のバージョンでは mariadb に統一されつつあるような印象を受けます。

最新版GAの 10.3 をインストールするには、MaraiDB 公式レポジトリからインストールする必要があります。

mysql(MariaDB monitor)によるmysqldへの接続

Debian / Ubuntu の最近のバージョンでは、rootユーザに対して unix_socket プラグインが有効になっていますので、OSのrootユーザ以外では mysql で MariaDB サーバに接続できません。

$ whoami
vagrant
$ mysql -u root
ERROR 1698 (28000): Access denied for user 'root'@'localhost'

sudo をつけるか、sudo su - などで root になってから mysql(mariadb)コマンドを実行するとDBサーバに接続できます。

$ sudo mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 19
Server version: 10.1.26-MariaDB-0+deb9u1 Debian 9.1

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

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

MariaDB [(none)]> SELECT user,host,password,plugin FROM mysql.user;
+------+-----------+----------+-------------+
| user | host      | password | plugin      |
+------+-----------+----------+-------------+
| root | localhost |          | unix_socket |
+------+-----------+----------+-------------+

unix_socket plugin を無効にする

MariaDB [mysql]> update mysql.user set plugin='' where user='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

MariaDB [mysql]> select user,host,plugin from mysql.user;
+-------+-----------+--------+
| user  | host      | plugin |
+-------+-----------+--------+
| root  | localhost |        |
+-------+-----------+--------+

参考リンク: https://mariadb.com/kb/en/library/authentication-plugin-unix-socket/

The UNIX_SOCKET plugin is installed by default in new installs of Ubuntu 15.10 and later, and Debian testing.

P.S. Markdownで表を作成するのは煩雑なので、https://donatstudios.com/CsvToMarkdownTable を用いました。

4
2
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
4
2