FreeBSD 12.2-RELEASE に MySQL 8.0 を入れる2020年11月15日 13時03分14秒

FreeBSD 12.2-RELEASE 時点で最新の MySQL は 8.0 の様。MySQL が動くための最低限の設定でいく。実は PostgreSQL を入れた 12.0-RELEASE の時は MySQL の pkg が壊れていた。MySQL の方が、PostgreSQL よりも一つ少ない二つのコマンドで利用が出来る。

まずは、pkg でインストール。

# pkg install mysql80-server mysql80-client
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
The following 9 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
        mysql80-server: 8.0.17
        mysql80-client: 8.0.17
        perl5: 5.30.0
        re2: 20190701_1
        protobuf: 3.9.2,1
        libunwind: 20170615
        libevent: 2.1.11
        libedit: 3.1.20190324,1
        icu: 64.2,1

Number of packages to be installed: 9

The process will require 399 MiB more space.
23 MiB to be downloaded.

Proceed with this action? [y/N]

...

[9/9] Installing mysql80-server-8.0.17...
===> Creating groups.
Using existing group 'mysql'.
===> Creating users
Using existing user 'mysql'.
[9/9] Extracting mysql80-server-8.0.17: 100%
=====
Message from perl5-5.30.0:

--
The /usr/bin/perl symlink has been removed starting with Perl 5.20.
For shebangs, you should either use:

#!/usr/local/bin/perl

or

#!/usr/bin/env perl

The first one will only work if you have a /usr/local/bin/perl,
the second will work as long as perl is in PATH.
=====
Message from mysql80-client-8.0.17:

--
This is the mysql CLIENT without the server.
for complete server and client, please install databases/mysql80-server
=====
Message from mysql80-server-8.0.17:

--
There is no initial password for first time use of MySQL.
Keep in mind to reset it to a secure password.

MySQL80 has a default %%ETCDIR%%/my.cnf,
remember to replace it with your own
or set `mysql_optfile="$YOUR_CNF_FILE` in rc.conf.

rc.conf に mysql_enable と追加して、起動する。

# echo 'mysql_enable="YES"' >> /etc/rc.conf
# /usr/local/etc/rc.d/mysql-server start
Starting mysql.
rc.d ファイルを起動する、「service」 と言うコマンドが存在する。そちらでも可。
# service mysql-server start
普段使わない /usr/local/etc/rc.d のファイル名は大体忘れてる。その為、/usr/local/etc/rc.d から始めて、オートコンプリートを使いつつ、起動したいスクリプトを探す。それ故、起動するスクリプトの名前を知らないと動かせない service スクリプトは、個人的に利用頻度がとても低い。

mysql で root ユーザとして接続できる。

% mysql
ERROR 1045 (28000): Access denied for user 'uyota'@'localhost' (using password:
NO)
% mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.17 Source distribution

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

root@localhost [(none)]> SELECT 1;
+---+
| 1 |
+---+
| 1 |
+---+
1 row in set (0.00 sec)

root@localhost [(none)]>
本来ならばこれ以降に、パスワードの設定などを行うのだが、一時的な利用なので省略。

前回次回