最近の変更サイトマップ

FreeBSD 10.1RにMariaDB 10.0をインストール

サーバ環境を一新したのでMySQLもMariaDBに乗り換えてみるテスツ。

環境

  • FreeBSD 10.1-RELEASE-p10
  • MariaDB 10.0.21
  • DBデータは /usr/home/mysql/data に置く

インストール

サーバを入れるとクライアントも一緒に入る。 MySQLで指定していたWITH_CHARSET, WITH_XCHARSETmake.confで一応指定したけど、正規の指定方法なのか、正しく機能しているかは確認してない。 (2018-10-19)mysql55で同オプションは廃止されており指定しても意味はない。

sudo portmaster databases/mariadb100-server

設定

MariaDBはMySQL 5.5からフォークしたものなので、各種設定方法もMySQL 5.5のものを継承してると考えていいのかな、きっと、多分。

データ置き場とmy.cnfの準備

sudo mkdir -p /home/mysql/data
sudo chown -R mysql:mysql /home/mysql
sudo cp -p /usr/local/share/mysql/my-huge.cnf /usr/local/etc/my.cnf

最近(といってもここ数年)のマシンならmy-huge.cnfで問題ないと思われる。

起動設定

データ置き場を変えてるので、mysql_dbdirの設定も忘れずに。

mysql_enable="YES"
mysql_dbdir="/usr/home/mysql/data/"

文字コードをUTF-8にする

/usr/local/etc/my.cnfの各セクションに追加。

[client]
...
default-character-set=utf8

[mysqld]
...
character-set-server=utf8

サーバ起動&セキュリティ設定

$ sudo /usr/local/etc/rc.d/mysql-server start
$ sudo 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):
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]
New password:
Re-enter new password:
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]
 ... 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]
 ... 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]
 - 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]
 ... 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 -u root -p
Enter password:
MariaDB [(none)]> show variables like "chara%";
+--------------------------+----------------------------------+
| Variable_name            | Value                            |
+--------------------------+----------------------------------+
| character_set_client     | utf8                             |
| character_set_connection | utf8                             |
| character_set_database   | utf8                             |
| character_set_filesystem | binary                           |
| character_set_results    | utf8                             |
| character_set_server     | utf8                             |
| character_set_system     | utf8                             |
| character_sets_dir       | /usr/local/share/mysql/charsets/ |
+--------------------------+----------------------------------+
8 rows in set (0.00 sec)
freebsd/freebsd_10.1r_install_mariadb_10.0.txt · 最終更新: 2018-10-19 15:06 by decomo
CC Attribution-Noncommercial-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0