# curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | bash -s -- --help
Usage: curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | bash -s -- [OPTIONS]
https://mariadb.com/kb/en/mariadb/mariadb-package-repository-setup-and-usage/
The MariaDB Repository supports these Linux OSs, on x86-64 only:
* RHEL/CentOS 6 & 7
* Ubuntu 14.04 LTS (trusty), 16.04 LTS (xenial), & 18.04 LTS (bionic)
* Debian 8 (jessie) & 9 (stretch)
* SLES 12 & 15
Options:
--help Display this help and exit.
--mariadb-server-version=<version>
Override the default MariaDB Server version.
By default, the script will use 'mariadb-10.3'.
--mariadb-maxscale-version=<version>
Override the default MariaDB MaxScale version.
By default, the script will use '2.3'.
--os-type=<type> Override detection of OS type. Acceptable values include
'debian', 'ubuntu', 'rhel', and 'sles'.
--os-version=<version> Override detection of OS version. Acceptable values depend
on the OS type you specify.
--skip-key-import Skip importing GPG signing keys.
--skip-maxscale Skip the 'MaxScale' repository.
--skip-server Skip the 'MariaDB Server' repository.
--skip-tools Skip the 'Tools' repository.
--write-to-stdout Write output to stdout instead of to the OS's
repository configuration. This will also skip
importing GPG keys and updating the package
cache on platforms where that behavior exists.
# cat /etc/yum.repos.d/mariadb.repo
[mariadb-main]
name = MariaDB Server
baseurl = https://downloads.mariadb.com/MariaDB/mariadb-10.3/yum/rhel/$releasever/$basearch
gpgkey = file:///etc/pki/rpm-gpg/MariaDB-Server-GPG-KEY
gpgcheck = 1
enabled = 1
[mariadb-maxscale]
# To use the latest stable release of MaxScale, use “latest” as the version
# To use the latest beta (or stable if no current beta) release of MaxScale, use “beta” as the version
name = MariaDB MaxScale
baseurl = https://downloads.mariadb.com/MaxScale/2.3/centos/$releasever/$basearch
gpgkey = file:///etc/pki/rpm-gpg/MariaDB-MaxScale-GPG-KEY
gpgcheck = 1
enabled = 1
[mariadb-tools]
name = MariaDB Tools
baseurl = https://downloads.mariadb.com/Tools/rhel/$releasever/$basearch
gpgkey = file:///etc/pki/rpm-gpg/MariaDB-Enterprise-GPG-KEY
gpgcheck = 1
enabled = 1
正常に最新のMariaDBのリポジトリが追加されました。
MariaDBインストール
yumでMariaDBをインストールします。
# yum -y install MariaDB-devel MariaDB-client MariaDB-server
読み込んだプラグイン:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: ftp-srv2.kddilabs.jp
* epel: ftp.iij.ad.jp
* epel-debuginfo: ftp.iij.ad.jp
* epel-source: ftp.iij.ad.jp
* extras: ftp-srv2.kddilabs.jp
* updates: ftp-srv2.kddilabs.jp
mariadb-main | 2.9 kB 00:00:00
mariadb-maxscale | 2.4 kB 00:00:00
mariadb-tools | 2.9 kB 00:00:00
(1/3): mariadb-tools/7/x86_64/primary_db | 11 kB 00:00:01
(2/3): mariadb-maxscale/7/x86_64/primary_db | 6.7 kB 00:00:01
(3/3): mariadb-main/7/x86_64/primary_db | 50 kB 00:00:01
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> パッケージ MariaDB-client.x86_64 0:10.3.12-1.el7.centos を インストール
--> 依存性の処理をしています: MariaDB-common のパッケージ: MariaDB-client-10.3.12-1.el7.centos.x86_64
---> パッケージ MariaDB-devel.x86_64 0:10.3.12-1.el7.centos を インストール
---> パッケージ MariaDB-server.x86_64 0:10.3.12-1.el7.centos を インストール
--> 依存性の処理をしています: perl(DBI) のパッケージ: MariaDB-server-10.3.12-1.el7.centos.x86_64
--> 依存性の処理をしています: galera のパッケージ: MariaDB-server-10.3.12-1.el7.centos.x86_64
--> 依存性の処理をしています: perl(Data::Dumper) のパッケージ: MariaDB-server-10.3.12-1.el7.centos.x86_64
--> トランザクションの確認を実行しています。
---> パッケージ MariaDB-common.x86_64 0:10.3.12-1.el7.centos を インストール
--> 依存性の処理をしています: MariaDB-compat のパッケージ: MariaDB-common-10.3.12-1.el7.centos.x86_64
---> パッケージ galera.x86_64 0:25.3.25-1.rhel7.el7.centos を インストール
--> 依存性の処理をしています: libboost_program_options.so.1.53.0()(64bit) のパッケージ: galera-25.3.25-1.rhel7.el7.centos.x86_64
---> パッケージ perl-DBI.x86_64 0:1.627-4.el7 を インストール
--> 依存性の処理をしています: perl(RPC::PlServer) >= 0.2001 のパッケージ: perl-DBI-1.627-4.el7.x86_64
--> 依存性の処理をしています: perl(RPC::PlClient) >= 0.2000 のパッケージ: perl-DBI-1.627-4.el7.x86_64
---> パッケージ perl-Data-Dumper.x86_64 0:2.145-3.el7 を インストール
--> トランザクションの確認を実行しています。
---> パッケージ MariaDB-compat.x86_64 0:10.3.12-1.el7.centos を 非推奨
---> パッケージ boost-program-options.x86_64 0:1.53.0-27.el7 を インストール
---> パッケージ mariadb-libs.x86_64 1:5.5.60-1.el7_5 を 不要
---> パッケージ perl-PlRPC.noarch 0:0.2020-14.el7 を インストール
--> 依存性の処理をしています: perl(Net::Daemon) >= 0.13 のパッケージ: perl-PlRPC-0.2020-14.el7.noarch
--> 依存性の処理をしています: perl(Net::Daemon::Test) のパッケージ: perl-PlRPC-0.2020-14.el7.noarch
--> 依存性の処理をしています: perl(Net::Daemon::Log) のパッケージ: perl-PlRPC-0.2020-14.el7.noarch
--> 依存性の処理をしています: perl(Compress::Zlib) のパッケージ: perl-PlRPC-0.2020-14.el7.noarch
--> トランザクションの確認を実行しています。
---> パッケージ perl-IO-Compress.noarch 0:2.061-2.el7 を インストール
--> 依存性の処理をしています: perl(Compress::Raw::Zlib) >= 2.061 のパッケージ: perl-IO-Compress-2.061-2.el7.noarch
--> 依存性の処理をしています: perl(Compress::Raw::Bzip2) >= 2.061 のパッケージ: perl-IO-Compress-2.061-2.el7.noarch
---> パッケージ perl-Net-Daemon.noarch 0:0.48-5.el7 を インストール
--> トランザクションの確認を実行しています。
---> パッケージ perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 を インストール
---> パッケージ perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7 を インストール
--> 依存性解決を終了しました。
依存性を解決しました
========================================================================================================================
Package アーキテクチャー バージョン リポジトリー 容量
========================================================================================================================
インストール中:
MariaDB-client x86_64 10.3.12-1.el7.centos mariadb-main 53 M
MariaDB-compat x86_64 10.3.12-1.el7.centos mariadb-main 2.8 M
mariadb-libs.x86_64 1:5.5.60-1.el7_5 を入れ替えます
MariaDB-devel x86_64 10.3.12-1.el7.centos mariadb-main 7.0 M
MariaDB-server x86_64 10.3.12-1.el7.centos mariadb-main 123 M
依存性関連でのインストールをします:
MariaDB-common x86_64 10.3.12-1.el7.centos mariadb-main 166 k
boost-program-options x86_64 1.53.0-27.el7 base 156 k
galera x86_64 25.3.25-1.rhel7.el7.centos mariadb-main 8.1 M
perl-Compress-Raw-Bzip2 x86_64 2.061-3.el7 base 32 k
perl-Compress-Raw-Zlib x86_64 1:2.061-4.el7 base 57 k
perl-DBI x86_64 1.627-4.el7 base 802 k
perl-Data-Dumper x86_64 2.145-3.el7 base 47 k
perl-IO-Compress noarch 2.061-2.el7 base 260 k
perl-Net-Daemon noarch 0.48-5.el7 base 51 k
perl-PlRPC noarch 0.2020-14.el7 base 36 k
トランザクションの要約
========================================================================================================================
インストール 4 パッケージ (+10 個の依存関係のパッケージ)
総ダウンロード容量: 196 M
Downloading packages:
(1/14): MariaDB-10.3.12-centos73-x86_64-common.rpm | 166 kB 00:00:02
(2/14): MariaDB-10.3.12-centos73-x86_64-compat.rpm | 2.8 MB 00:00:01
(3/14): MariaDB-10.3.12-centos73-x86_64-devel.rpm | 7.0 MB 00:00:01
(4/14): boost-program-options-1.53.0-27.el7.x86_64.rpm | 156 kB 00:00:00
(5/14): MariaDB-10.3.12-centos73-x86_64-client.rpm | 53 MB 00:00:12
(6/14): perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64.rpm | 32 kB 00:00:00
(7/14): perl-Data-Dumper-2.145-3.el7.x86_64.rpm | 47 kB 00:00:00
(8/14): perl-IO-Compress-2.061-2.el7.noarch.rpm | 260 kB 00:00:00
(9/14): perl-Net-Daemon-0.48-5.el7.noarch.rpm | 51 kB 00:00:00
(10/14): perl-PlRPC-0.2020-14.el7.noarch.rpm | 36 kB 00:00:00
(11/14): perl-Compress-Raw-Zlib-2.061-4.el7.x86_64.rpm | 57 kB 00:00:00
(12/14): perl-DBI-1.627-4.el7.x86_64.rpm | 802 kB 00:00:00
(13/14): galera-25.3.25-1.rhel7.el7.centos.x86_64.rpm | 8.1 MB 00:00:01
(14/14): MariaDB-10.3.12-centos73-x86_64-server.rpm | 123 MB 00:00:24
------------------------------------------------------------------------------------------------------------------------
合計 6.6 MB/s | 196 MB 00:00:29
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
インストール中 : perl-Data-Dumper-2.145-3.el7.x86_64 1/15
インストール中 : MariaDB-common-10.3.12-1.el7.centos.x86_64 2/15
インストール中 : MariaDB-compat-10.3.12-1.el7.centos.x86_64 3/15
インストール中 : MariaDB-client-10.3.12-1.el7.centos.x86_64 4/15
インストール中 : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64 5/15
インストール中 : boost-program-options-1.53.0-27.el7.x86_64 6/15
インストール中 : galera-25.3.25-1.rhel7.el7.centos.x86_64 7/15
インストール中 : perl-Net-Daemon-0.48-5.el7.noarch 8/15
インストール中 : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64 9/15
インストール中 : perl-IO-Compress-2.061-2.el7.noarch 10/15
インストール中 : perl-PlRPC-0.2020-14.el7.noarch 11/15
インストール中 : perl-DBI-1.627-4.el7.x86_64 12/15
インストール中 : MariaDB-server-10.3.12-1.el7.centos.x86_64 13/15
chown: ユーザ指定が不正: `mysql'
PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
To do so, start the server, then issue the following commands:
'/usr/bin/mysqladmin' -u root password 'new-password'
'/usr/bin/mysqladmin' -u root -h 150-95-187-132 password 'new-password'
Alternatively you can run:
'/usr/bin/mysql_secure_installation'
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the MariaDB Knowledgebase at http://mariadb.com/kb or the
MySQL manual for more instructions.
Please report any problems at http://mariadb.org/jira
The latest information about MariaDB is available at http://mariadb.org/.
You can find additional information about the MySQL part at:
http://dev.mysql.com
Consider joining MariaDB's strong and vibrant community:
# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none): ■ここでEnterキーを押す。
rootパスワードがまだ未設定なので何も入力せずEnterキーを押します。
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] ■Yと記入してEnterキーを押す。
rootパスワードを新規に設定するので「Y」と記入してからEnterキーを押します。
New password: ■rootパスワードを入力してEnterキーを押す。
Re-enter new password: ■再度rootパスワードを入力してEnterキーを押す。
rootパスワードを二度記入してEnterキーを押します。
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] ■Yと記入してEnterキーを押す。
匿名ユーザーを削除するか聞いてきますので「Y」と記入してからEnterキーを押します。
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] ■Yと記入してEnterキーを押す。
... Success!
By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] ■Yと記入してEnterキーを押す。
test用のデータベースを削除するか聞いてくるので「Y」と記入してからEnterキーを押します。
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] ■Yと記入してEnterキーを押す。
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
これでmysql_secure_installationは終了です。
不要なユーザーや不要なデータベースを削除してセキュリティが高まりました。
続いて「文字セット(charset)のutf8mb4化」を行います。
文字セット(charset)のutf8mb4化
現在のMariaDBの文字セット(charset)を確認
まず、現在のMariaDBの文字セット(charset)の状態を確認します。
「mysql -u root -p」でMariaDBにログインします。
# mysql -u root -p
Enter password: ■rootパスワードを入力
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 16
Server version: 10.3.12-MariaDB MariaDB Server
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 variables like 'char%';」と入力してEnterキーで現在の文字セット(charset)の状態を表示します。
#
# These groups are read by MariaDB server.
# Use it for options that only the server (but not clients) should see
#
# See the examples of server my.cnf files in /usr/share/mysql/
#
# this is read by the standalone daemon and embedded servers
[server]
# this is only for the mysqld standalone daemon
[mysqld]
#
# * Galera-related settings
#
[galera]
# Mandatory settings
#wsrep_on=ON
#wsrep_provider=
#wsrep_cluster_address=
#binlog_format=row
#default_storage_engine=InnoDB
#innodb_autoinc_lock_mode=2
#
# Allow server to accept connections on all interfaces.
# #bind-address=0.0.0.0
#
# Optional setting
#wsrep_slave_threads=1
#innodb_flush_log_at_trx_commit=0
# this is only for embedded server
[embedded]
# This group is only read by MariaDB servers, not by MySQL.
# If you use the same .cnf file for MySQL and MariaDB, # you can put MariaDB-only options here
[mariadb]
character-set-server = utf8mb4 #■追加
[client-mariadb] #■追加
default-character-set = utf8mb4 #■追加
# This group is only read by MariaDB-10.3 servers.
# If you use the same .cnf file for MariaDB of different versions,
# use this group for options that older servers don’t understand
[mariadb-10.3]
MariaDBの文字セット(charset)がちゃんとutf8mb4に変更されているか、もう一度MariaDBにログインして「show variables like 'char%';」と「show variables like 'coll%';」で確認します。
# mysql -u root -p
Enter password: ■rootパスワードを入力
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.3.12-MariaDB MariaDB Server
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 variables like 'char%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8mb4 |
| character_set_connection | utf8mb4 |
| character_set_database | utf8mb4 |
| character_set_filesystem | binary |
| character_set_results | utf8mb4 |
| character_set_server | utf8mb4 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.002 sec)
MariaDB [(none)]> show variables like 'coll%';
+----------------------+--------------------+
| Variable_name | Value |
+----------------------+--------------------+
| collation_connection | utf8mb4_general_ci |
| collation_database | utf8mb4_general_ci |
| collation_server | utf8mb4_general_ci |
+----------------------+--------------------+
3 rows in set (0.001 sec)
MariaDB [(none)]> exit;
Bye