Pi/Server/Raspbian busterにMariaDBをインストール
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
]
開始行:
#navi(../)
* Raspbian busterにMariaDBをインストール [#b3d497cb]
本記事では、ラズベリーパイのRaspbian busterにMariaDBをイ...
ユーザ追加、データベース作成、SQLを実行までの記事になりま...
#htmlinsert(minipc-top.html)
#contents
* 関連記事 [#l2b67a88]
-[[Raspbian busterにPostgreSQLをインストール>Pi/Server/Ra...
-[[Raspbian busterにSQLite3をインストール>Pi/Server/Raspb...
-[[Raspbian busterにMariaDBをインストール>Pi/Server/Raspb...
* 使用した環境 [#g657fe68]
-Raspberry Pi 3B+~
[[Raspberry Pi(Amazonへのリンク)>https://amzn.to/2IIrAhM]]
- Raspbian OS
$ lsb_release -dr
Description: Raspbian GNU/Linux 10 (buster)
* MariaDBパッケージをインストールする [#t61a0715]
LXTerminal &ref(t.png); を使ってaptコマンドでMariaDBをイ...
+ MariaDBパッケージインストール前に以下のコマンドを実行し...
sudo apt update
sudo apt -y upgrade
+ MariaDBパッケージを以下のコマンドを実行しインストールし...
sudo apt install mariadb-server -y
ちなみにインストールするmariadb-serverパッケージの情報は...
apt showコマンドで確認することができます。~
$ apt show mariadb-server
Package: mariadb-server
Version: 1:10.3.15-1
Priority: optional
Section: database
Source: mariadb-10.3
Maintainer: Debian MySQL Maintainers <pkg-mysql-maint@li...
Installed-Size: 66.6 kB
Depends: mariadb-server-10.3 (>= 1:10.3.15-1)
Homepage: https://mariadb.org/
Tag: devel::lang:c++, devel::lang:sql, devel::library, i...
interface::commandline, interface::daemon, network::ser...
protocol::db:mysql, role::devel-lib, role::metapackage,...
works-with::db
Download-Size: 30.2 kB
APT-Sources: http://ftp.jaist.ac.jp/raspbian buster/main...
Description: MariaDB database server (metapackage depend...
This is an empty package that depends on the current "b...
mariadb-server (currently mariadb-server-10.3), as dete...
maintainers. Install this package if in doubt about whi...
version you need. That will install the version recomme...
package maintainers.
.
MariaDB is a fast, stable and true multi-user, multi-th...
server. SQL (Structured Query Language) is the most pop...
language in the world. The main goals of MariaDB are sp...
ease of use.
+インストール中のメッセージは以下の通りです。~
$ sudo apt install mariadb-server -y
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています
状態情報を読み取っています... 完了
以下の追加パッケージがインストールされます:
galera-3 gawk libaio1 libcgi-fast-perl libcgi-pm-perl
libconfig-inifiles-perl libdbd-mysql-perl libdbi-perl ...
<省略>
プロンプト($)が戻ってくればMariaDBのインストールは完了で...
* collation-serverの変更 [#x5206858]
/etc/mysql/mariadb.conf.d/50-server.cnf にサーバの文字コ...
デフォルト(インストール時点)では以下の通りです。
#
# * Character sets
#
# MySQL/MariaDB default is Latin1, but in Debian we rath...
# utf8 4-byte character set. See also client.cnf
#
character-set-server = utf8mb4
collation-server = utf8mb4_general_ci
必要に応じて変更してください。~
本記事では、collation-serverの設定値を(''utf8mb4_bin'')に...
#collation-server = utf8mb4_general_ci
collation-server = utf8mb4_bin
#ref(01.png)
#br
/etc/mysql/mariadb.conf.d/50-server.cnf の変更が終わった...
sudo systemctl restart mariadb
* MariaDB初期設定 [#s6d572c8]
+MariaDBの初期設定を以下のコマンドで実施します。
sudo mysql_secure_installation
+rootパスワードを設定します。~
基本はすべてEnterキーで構いませんが、以下のメッセージが表...
MariaDBのrootパスワードを設定してください。(大文字英字が...
Set root password? [Y/n]
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
+以下のメッセージが表示されプロンプトが表示されたらMariaD...
Thanks for using MariaDB!
* MariaDBの動作確認 [#geefb216]
MariaDBへの接続、SQLの発行を試してみます。
$ sudo mariadb -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or ...
Your MariaDB connection id is 46
Server version: 10.3.15-MariaDB-1 Raspbian testing-staging
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab...
Type 'help;' or '\h' for help. Type '\c' to clear the cu...
MariaDB [(none)]>
SQLを実行してみる
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
3 rows in set (0.002 sec)
MariaDB [(none)]> select now();
+---------------------+
| now() |
+---------------------+
| 2019-08-04 01:56:41 |
+---------------------+
1 row in set (0.001 sec)
MariaDB [(none)]> exit
Bye
ちなみに上記では、mysqlではなく、mariadbコマンドで実行し...
もちろん、mysqlコマンドでも同様に動作します。~
mariadbコマンドはmysqlコマンドのシンボリックリンクです。
$ file $(which mariadb)
/usr/bin/mariadb: symbolic link to mysql
$ ls -l $(which mariadb)
lrwxrwxrwx 1 root root 5 5月 21 16:45 /usr/bin/mariadb ...
以上、ラズパイ(Raspbian buster)にMariaDBをインストールし...
#htmlinsert(minipc-btm.html)
終了行:
#navi(../)
* Raspbian busterにMariaDBをインストール [#b3d497cb]
本記事では、ラズベリーパイのRaspbian busterにMariaDBをイ...
ユーザ追加、データベース作成、SQLを実行までの記事になりま...
#htmlinsert(minipc-top.html)
#contents
* 関連記事 [#l2b67a88]
-[[Raspbian busterにPostgreSQLをインストール>Pi/Server/Ra...
-[[Raspbian busterにSQLite3をインストール>Pi/Server/Raspb...
-[[Raspbian busterにMariaDBをインストール>Pi/Server/Raspb...
* 使用した環境 [#g657fe68]
-Raspberry Pi 3B+~
[[Raspberry Pi(Amazonへのリンク)>https://amzn.to/2IIrAhM]]
- Raspbian OS
$ lsb_release -dr
Description: Raspbian GNU/Linux 10 (buster)
* MariaDBパッケージをインストールする [#t61a0715]
LXTerminal &ref(t.png); を使ってaptコマンドでMariaDBをイ...
+ MariaDBパッケージインストール前に以下のコマンドを実行し...
sudo apt update
sudo apt -y upgrade
+ MariaDBパッケージを以下のコマンドを実行しインストールし...
sudo apt install mariadb-server -y
ちなみにインストールするmariadb-serverパッケージの情報は...
apt showコマンドで確認することができます。~
$ apt show mariadb-server
Package: mariadb-server
Version: 1:10.3.15-1
Priority: optional
Section: database
Source: mariadb-10.3
Maintainer: Debian MySQL Maintainers <pkg-mysql-maint@li...
Installed-Size: 66.6 kB
Depends: mariadb-server-10.3 (>= 1:10.3.15-1)
Homepage: https://mariadb.org/
Tag: devel::lang:c++, devel::lang:sql, devel::library, i...
interface::commandline, interface::daemon, network::ser...
protocol::db:mysql, role::devel-lib, role::metapackage,...
works-with::db
Download-Size: 30.2 kB
APT-Sources: http://ftp.jaist.ac.jp/raspbian buster/main...
Description: MariaDB database server (metapackage depend...
This is an empty package that depends on the current "b...
mariadb-server (currently mariadb-server-10.3), as dete...
maintainers. Install this package if in doubt about whi...
version you need. That will install the version recomme...
package maintainers.
.
MariaDB is a fast, stable and true multi-user, multi-th...
server. SQL (Structured Query Language) is the most pop...
language in the world. The main goals of MariaDB are sp...
ease of use.
+インストール中のメッセージは以下の通りです。~
$ sudo apt install mariadb-server -y
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています
状態情報を読み取っています... 完了
以下の追加パッケージがインストールされます:
galera-3 gawk libaio1 libcgi-fast-perl libcgi-pm-perl
libconfig-inifiles-perl libdbd-mysql-perl libdbi-perl ...
<省略>
プロンプト($)が戻ってくればMariaDBのインストールは完了で...
* collation-serverの変更 [#x5206858]
/etc/mysql/mariadb.conf.d/50-server.cnf にサーバの文字コ...
デフォルト(インストール時点)では以下の通りです。
#
# * Character sets
#
# MySQL/MariaDB default is Latin1, but in Debian we rath...
# utf8 4-byte character set. See also client.cnf
#
character-set-server = utf8mb4
collation-server = utf8mb4_general_ci
必要に応じて変更してください。~
本記事では、collation-serverの設定値を(''utf8mb4_bin'')に...
#collation-server = utf8mb4_general_ci
collation-server = utf8mb4_bin
#ref(01.png)
#br
/etc/mysql/mariadb.conf.d/50-server.cnf の変更が終わった...
sudo systemctl restart mariadb
* MariaDB初期設定 [#s6d572c8]
+MariaDBの初期設定を以下のコマンドで実施します。
sudo mysql_secure_installation
+rootパスワードを設定します。~
基本はすべてEnterキーで構いませんが、以下のメッセージが表...
MariaDBのrootパスワードを設定してください。(大文字英字が...
Set root password? [Y/n]
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
+以下のメッセージが表示されプロンプトが表示されたらMariaD...
Thanks for using MariaDB!
* MariaDBの動作確認 [#geefb216]
MariaDBへの接続、SQLの発行を試してみます。
$ sudo mariadb -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or ...
Your MariaDB connection id is 46
Server version: 10.3.15-MariaDB-1 Raspbian testing-staging
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab...
Type 'help;' or '\h' for help. Type '\c' to clear the cu...
MariaDB [(none)]>
SQLを実行してみる
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
3 rows in set (0.002 sec)
MariaDB [(none)]> select now();
+---------------------+
| now() |
+---------------------+
| 2019-08-04 01:56:41 |
+---------------------+
1 row in set (0.001 sec)
MariaDB [(none)]> exit
Bye
ちなみに上記では、mysqlではなく、mariadbコマンドで実行し...
もちろん、mysqlコマンドでも同様に動作します。~
mariadbコマンドはmysqlコマンドのシンボリックリンクです。
$ file $(which mariadb)
/usr/bin/mariadb: symbolic link to mysql
$ ls -l $(which mariadb)
lrwxrwxrwx 1 root root 5 5月 21 16:45 /usr/bin/mariadb ...
以上、ラズパイ(Raspbian buster)にMariaDBをインストールし...
#htmlinsert(minipc-btm.html)
ページ名: