freebsd:freebsd_10.1r_install_mariadb_10.0

差分

このページの2つのバージョン間の差分を表示します。

この比較画面にリンクする

両方とも前のリビジョン 前のリビジョン
前のリビジョン
freebsd:freebsd_10.1r_install_mariadb_10.0 [2015-11-01 20:06]
freebsd:freebsd_10.1r_install_mariadb_10.0 [2021-02-01 09:57] (現在)
Decomo
行 1: 行 1:
 +====== FreeBSD 10.1RにMariaDB 10.0をインストール ======
 +
 +サーバ環境を一新したのでMySQLもMariaDBに乗り換えてみるテスツ。
 +
 +===== 環境 =====
 +
 +  * FreeBSD 10.1-RELEASE-p10
 +  * MariaDB 10.0.21
 +  * DBデータは /usr/home/mysql/data に置く
 +
 +===== インストール =====
 +
 +サーバを入れるとクライアントも一緒に入る。
 +<del>[[freebsd_9.1r_install_mysql_5.5|MySQLで指定していたWITH_CHARSET, WITH_XCHARSET]]も''make.conf''で一応指定したけど、正規の指定方法なのか、正しく機能しているかは確認してない。</del> (2018-10-19)mysql55で同オプションは廃止されており指定しても意味はない。
 +
 +<code>
 +sudo portmaster databases/mariadb100-server
 +</code>
 +
 +===== 設定 =====
 +
 +MariaDBはMySQL 5.5からフォークしたものなので、各種設定方法もMySQL 5.5のものを継承してると考えていいのかな、きっと、多分。
 +
 +==== データ置き場とmy.cnfの準備 ====
 +
 +<code>
 +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
 +</code>
 +
 +最近(といってもここ数年)のマシンならmy-huge.cnfで問題ないと思われる。
 +
 +==== 起動設定 ====
 +
 +データ置き場を変えてるので、''mysql_dbdir''の設定も忘れずに。
 +
 +<code>
 +mysql_enable="YES"
 +mysql_dbdir="/usr/home/mysql/data/"
 +</code>
 +
 +==== 文字コードをUTF-8にする ====
 +
 +/usr/local/etc/my.cnfの各セクションに追加。
 +
 +<code>
 +[client]
 +...
 +default-character-set=utf8
 +
 +[mysqld]
 +...
 +character-set-server=utf8
 +</code>
 +
 +==== サーバ起動&セキュリティ設定 ====
 +
 +<code>
 +$ 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!
 +</code>
 +
 +==== 試しに繋いでみる ====
 +
 +ついでに文字コード設定が正しく効いてるかも確認。
 +
 +<code>
 +$ 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)
 +</code>
 +