end0tknr's kipple - web写経開発

太宰府天満宮の狛犬って、妙にカワイイ

installing mysql9.0 source distribution to oraclie linux 8.7

目次

参考url

install先 - oracle linux 8.7

$ cat /etc/redhat-release 
Red Hat Enterprise Linux release 8.7 (Ootpa)  

$ cat /etc/os-release 
NAME="Oracle Linux Server"
VERSION="8.7"
ID="ol"
ID_LIKE="fedora"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="8.7"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Oracle Linux Server 8.7"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:oracle:linux:8:7:server"
HOME_URL="https://linux.oracle.com/"
BUG_REPORT_URL="https://bugzilla.oracle.com/"

ORACLE_BUGZILLA_PRODUCT="Oracle Linux 8"
ORACLE_BUGZILLA_PRODUCT_VERSION=8.7
ORACLE_SUPPORT_PRODUCT="Oracle Linux"
ORACLE_SUPPORT_PRODUCT_VERSION=8.7

依存library

https://end0tknr.hateblo.jp/entry/20220108/1641624999 を参考に、以下を yum install.

$ sudo yum install openssl-devel
$ sudo yum install ncurses-devel
$ sudo yum install libedit-devel
$ sudo yum install boost-devel
$ sudo yum install gcc-c++
$ sudo yum install libtirpc-devel
$ sudo yum install rpcgen

その後、cmakeを実行しましたが、以下も yum installするよう cmakeがメッセージを表示した為、追加

$ sudo yum install \
  gcc-toolset-13-gcc gcc-toolset-13-gcc-c++ \
  gcc-toolset-13-binutils gcc-toolset-13-annobin-annocheck \
  gcc-toolset-13-annobin-plugin-gcc

user & group追加

$ sudo groupadd mysql
$ sudo useradd -r -g mysql mysql

mysql9.0 source distribution の入手と解凍

$ wget https://dev.mysql.com/get/Downloads/MySQL-9.0/mysql-9.0.1.tar.gz
$ tar -xvf mysql-9.0.1.tar.gz 

cmakeによる configuration

尚、cmakeのオプションは以下を参照

https://dev.mysql.com/doc/refman/9.0/en/source-configuration-options.html

$ mkdir build
$ cd build
$ cmake .. \
   -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
   -DWITH_SYSTEMD=ON

make ~ make test ~ make install

make test で少々、failしましたが、無視し、make install しています。

$ make
$ sudo make test
  :
99% tests passed, 2 tests failed out of 305

Label Time Summary:
NDB    = 117.86 sec*proc (37 tests)

Total Test time (real) = 1394.25 sec

The following tests FAILED:
          8 - NdbGetInAddr-t (Failed)
        300 - routertest_integration_routing_sharing (Failed)
Errors while running CTest
Output from these tests are in: /home/end0tknr/tmp/mysql-9.0.1/build/Testing/Temporary/LastTest.log
Use "--rerun-failed --output-on-failure" to re-run the failed cases verbosely.
make: *** [Makefile:91: test] Error 8

$ sudo make install

my.cnfによる設定等

my.cnf は、makeにより作成されたものを https://end0tknr.hateblo.jp/entry/20220108/1641624999 も参考に編集

$ sudo cp ./packaging/rpm-common/my.cnf /etc/

$ suo vi /etc/my.cnf
[mysqld]
basedir = /usr/local/mysql
datadir = /var/mysql_data

socket=/tmp/mysql.sock
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

skip-grant-tables
default_password_lifetime=0
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

datadir作成や初期化

$ sudo mkdir /var/mysql_data
$ sudo chown mysql:mysql /var/mysql_data
$ sudo chmod 750 /var/mysql_data

$ sudo touch /var/log/mysqld.log
$ sudo chown mysql:mysql /var/log/mysqld.log

$ sudo mkdir /var/run/mysqld
$ sudo chown mysql:mysql /var/run/mysqld

mysqlのroot初期パスワードは /var/log/mysqld.log で確認できますが、 my.cnf で skip-grant-tables していますので、 パスワードなしでも、mysqlへ接続できます。

$ sudo /usr/local/mysql/bin/mysqld --initialize --user=mysql

$ sudo cat /var/log/mysqld.log
2024-08-11T01:36:03.034743Z 0 [System] [MY-015017] [Server] MySQL Server Initialization - start.
2024-08-11T01:36:03.036746Z 0 [Warning] [MY-010915] [Server] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
2024-08-11T01:36:03.036792Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 9.0.1) initializing of server in progress as process 271822
2024-08-11T01:36:03.060561Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2024-08-11T01:36:03.696142Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2024-08-11T01:36:05.836016Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: 9flrM#n<u:tg
2024-08-11T01:36:08.423575Z 0 [System] [MY-015018] [Server] MySQL Server Initialization - end.

systemd 自動起動

mysqlの systemd については https://blog.s-style.co.jp/2024/07/12276/ が分かりやすい気がします

$ sudo cp ./scripts/mysqld.service /etc/systemd/system/

$ sudo systemctl enable mysqld.service
Created symlink /etc/systemd/system/multi-user.target.wants/mysqld.service → /etc/systemd/system/mysqld.service.

$ sudo systemctl start mysqld.service

root による接続テスト

$ /usr/local/mysql/bin/mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 9.0.1 Source distribution

Copyright (c) 2000, 2024, Oracle and/or its affiliates.

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.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.02 sec)