こんにちは!シミダイ(@shimidai2100)です。
MariaDBをWindowsOSへインストールする手順とDBの作成手順を紹介します。
MariaDBとは
- MySQLを元に作成されてオープンソースデータベース
- 代表的なLinuxのディストリビューションでは標準データベースになりつつある
- GoogleやWikipediaなどもMariaDBを採用している
とこれからのデファクトスタンダードになるデータベースです。
インストール環境
今回のインストール環境は以下になります。
- iインストールするOS:Windows 10 64bit
- MariaDB Server:MariaDB 10.3 Series
MariaDBのダウンロード
まずはMariaDBのメディアをダウンロードします。
ダウンロードリンク:https://downloads.mariadb.org/
赤枠のDownloadボタンから最新版を選択します。
インストールメディア「mariadb-x.x.x-winxXX.msi」を設定します。
インストールするWindowsOSのBit数を間違えないようにしましょう。
MariaDBのインストール手順
ダウンロードした「mariadb-x.x.x-winxXX.msi」でインストール開始します。
インストールメディアを実行して「Next」を選択します。
「I Accept the terms in the License Agreement」を選択して「次へ」を選択します。
今回はMariaDB Serverとすべてのユーティリティを選択して「Next」を選択します。
rootのパスワードと文字コードをUTF-8で設定し、次へを選択します。
Service NameとBuffer pool sizeで設定し、次へを選択します。
特になにも選択せずに次へを選択する。
ここまで来たらInstallを選択します。
下の画面が表示されてばインストール完了です。
「MySQL Client」を起動して、インストールが完了していることを確認します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
Enter password: ******** Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 9 Server version: 10.3.7-MariaDB mariadb.org binary distribution Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | test | +--------------------+ 4 rows in set (0.001 sec) |
MariaDBにデータベースを作成
MariaDBでデータベースを作成します。手順の流れは以下になります。
- MySQL Clientでrootユーザでログイン
- データベース作成
- データベース作成ユーザの作成と権限の付与
下がデータベース作成コマンドになります。
1 2 |
create database <データベース名> character set utf8; grant all privileges on <データベース名>.* to <ユーザ名>@localhost identified by '<ログインパスワード>'; |
下が実際に「testdb」を作成する場合の例です。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
Enter password: ******** Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 9 Server version: 10.3.7-MariaDB mariadb.org binary distribution Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> create database testdb character set utf8; Query OK, 1 row affected (0.005 sec) MariaDB [(none)]> grant all privileges on testdb.* to testdb_user@localhost identified by 'testdb_user'; Query OK, 0 rows affected (0.001 sec) MariaDB [(none)]> MariaDB [(none)]> MariaDB [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | test | | testdb | +--------------------+ 5 rows in set (0.001 sec) |