MySQL8.0 on EC2(Ubuntu) のインストールとオプションファイル配置

12月 2, 2023Database,MySQL

概要

  • 今回は、MySQL on EC2(Ubuntu) を構築する際の手順を記載します。
  • AWSを使用していますが、RDS ではありません。MySQL on EC2 です!!
  • RDSに慣れてしまい、MySQL のオプションファイル配置が分からず検証を行いました。MySQL は8.0、EC2 のOS はUbuntu 22.04.3 LTS になります。

 

MySQL on EC2(Ubuntu) 構築

mysql-server 8.0 のインストール

  • MySQLインストールの事前準備として、Ubuntu OS の aptパッケージリストの更新、パッケージのアップデートを行います。
  • Ubuntu 22.04.2 LTS → Ubuntu 22.04.3 LTS に更新完了。
$ cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.2 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.2 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy

$ sudo apt-get update
$ sudo apt upgrade

$ cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.3 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.3 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
  • 続いて、apt install コマンドを使用し、mysql-server 8.0 をインストールします。インストールの途中経過は省略します。
$ sudo apt install mysql-server
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  libcgi-fast-perl libcgi-pm-perl libclone-perl libencode-locale-perl libevent-pthreads-2.1-7 libfcgi-bin libfcgi-perl libfcgi0ldbl libhtml-parser-perl
  libhtml-tagset-perl libhtml-template-perl libhttp-date-perl libhttp-message-perl libio-html-perl liblwp-mediatypes-perl libmecab2 libprotobuf-lite23
  libtimedate-perl liburi-perl mecab-ipadic mecab-ipadic-utf8 mecab-utils mysql-client-8.0 mysql-client-core-8.0 mysql-common mysql-server-8.0
  mysql-server-core-8.0
Suggested packages:
  libdata-dump-perl libipc-sharedcache-perl libbusiness-isbn-perl libwww-perl mailx tinyca
The following NEW packages will be installed:
  libcgi-fast-perl libcgi-pm-perl libclone-perl libencode-locale-perl libevent-pthreads-2.1-7 libfcgi-bin libfcgi-perl libfcgi0ldbl libhtml-parser-perl
  libhtml-tagset-perl libhtml-template-perl libhttp-date-perl libhttp-message-perl libio-html-perl liblwp-mediatypes-perl libmecab2 libprotobuf-lite23
  libtimedate-perl liburi-perl mecab-ipadic mecab-ipadic-utf8 mecab-utils mysql-client-8.0 mysql-client-core-8.0 mysql-common mysql-server
  mysql-server-8.0 mysql-server-core-8.0
0 upgraded, 28 newly installed, 0 to remove and 1 not upgraded.
Need to get 29.6 MB of archives.
After this operation, 243 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
  • mysql-server 8.0 のインストール後、mysqlサービスの状態を確認します。サービスの起動は必要なく、mysqlサービスは既に開始していました。
  • mysql のバージョンを確認しています。今回インストールしたバージョンは、8.0.35 になります。

 

$ systemctl status mysql
● mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2023-12-02 13:59:16 UTC; 1min 59s ago
    Process: 1429 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
   Main PID: 1437 (mysqld)
     Status: "Server is operational"
      Tasks: 37 (limit: 2329)
     Memory: 365.2M
        CPU: 1.586s
     CGroup: /system.slice/mysql.service
             └─1437 /usr/sbin/mysqld
$ which mysql
/usr/bin/mysql
$ mysql --version
mysql  Ver 8.0.35-0ubuntu0.22.04.1 for Linux on x86_64 ((Ubuntu))

 

MySQL のrootパスワード変更

  • MySQL にroot ユーザーで接続し、root のパスワードを設定しています。root のパスワード設定後(例: root-password)、パスワードを確認するため再度接続を行います。
$ sudo mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.35-0ubuntu0.22.04.1 (Ubuntu)

Copyright (c) 2000, 2023, 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>



mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'root-password';
Query OK, 0 rows affected (0.01 sec)

mysql> exit
Bye
$ sudo mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.35-0ubuntu0.22.04.1 (Ubuntu)

Copyright (c) 2000, 2023, 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> 

 

  • root 以外の管理ユーザーを作成し、権限を付与しています。(例: dbadmin)
  • 作成されているユーザーの一覧表示を行い、続けて、先ほど作成した管理ユーザー(例: dbadmin / dbadmin-password)の権限を確認しています。
mysql> CREATE USER 'dbadmin'@'localhost' IDENTIFIED BY 'dbadmin-password';
Query OK, 0 rows affected (0.01 sec)

mysql> GRANT ALL PRIVILEGES ON * . * TO 'dbadmin'@'localhost';
Query OK, 0 rows affected (0.02 sec)

mysql> SELECT host, user FROM mysql.user;
+-----------+------------------+
| host      | user             |
+-----------+------------------+
| localhost | dbadmin          |
| localhost | debian-sys-maint |
| localhost | mysql.infoschema |
| localhost | mysql.session    |
| localhost | mysql.sys        |
| localhost | root             |
+-----------+------------------+
6 rows in set (0.00 sec)

mysql> SHOW GRANTS FOR 'dbadmin'@'localhost';
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Grants for dbadmin@localhost                                                                                                                                            |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARYTABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER,CREATE TABLESPACE, CREATE ROLE, DROP ROLE ON *.* TO `dbadmin`@`localhost`                                                                                                                                            |
| GRANT APPLICATION_PASSWORD_ADMIN,AUDIT_ABORT_EXEMPT,AUDIT_ADMIN,AUTHENTICATION_POLICY_ADMIN,BACKUP_ADMIN,BINLOG_ADMIN,BINLOG_ENCRYPTION_ADMIN,CLONE_ADMIN,CONNECTION_ADMIN,ENCRYPTION_KEY_ADMIN,FIREWALL_EXEMPT,FLUSH_OPTIMIZER_COSTS,FLUSH_STATUS,FLUSH_TABLES,FLUSH_USER_RESOURCES,GROUP_REPLICATION_ADMIN,GROUP_REPLICATION_STREAM,INNODB_REDO_LOG_ARCHIVE,INNODB_REDO_LOG_ENABLE,PASSWORDLESS_USER_ADMIN,PERSIST_RO_VARIABLES_ADMIN,REPLICATION_APPLIER,REPLICATION_SLAVE_ADMIN,RESOURCE_GROUP_ADMIN,RESOURCE_GROUP_USER,ROLE_ADMIN,SENSITIVE_VARIABLES_OBSERVER,SERVICE_CONNECTION_ADMIN,SESSION_VARIABLES_ADMIN,SET_USER_ID,SHOW_ROUTINE,SYSTEM_USER,SYSTEM_VARIABLES_ADMIN,TABLE_ENCRYPTION_ADMIN,TELEMETRY_LOG_ADMIN,XA_RECOVER_ADMIN ON *.* TO `dbadmin`@`localhost` |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

mysql> 

 

MySQL のオプション変更

  • MySQL のオプションを変更します。変更前の設定を確認します。SHOW GLOBAL VARIABLES はオプションを表示するコマンドであり、LIKE 文で “log" に関する変数をフィルターします。
mysql> SHOW GLOBAL VARIABLES LIKE '%log%';
+------------------------------------------------+-------------------------------------------------+
| Variable_name                                  | Value                                           |
+------------------------------------------------+-------------------------------------------------+
| activate_all_roles_on_login                    | OFF                                             |
| back_log                                       | 151                                             |
| binlog_cache_size                              | 32768                                           |
| binlog_checksum                                | CRC32                                           |
| binlog_direct_non_transactional_updates        | OFF                                             |
| binlog_encryption                              | OFF                                             |
| binlog_error_action                            | ABORT_SERVER                                    |
| binlog_expire_logs_auto_purge                  | ON                                              |
| binlog_expire_logs_seconds                     | 2592000                                         |
| binlog_format                                  | ROW                                             |
| binlog_group_commit_sync_delay                 | 0                                               |
| binlog_group_commit_sync_no_delay_count        | 0                                               |
| binlog_gtid_simple_recovery                    | ON                                              |
| binlog_max_flush_queue_time                    | 0                                               |
| binlog_order_commits                           | ON                                              |
| binlog_rotate_encryption_master_key_at_startup | OFF                                             |
| binlog_row_event_max_size                      | 8192                                            |
| binlog_row_image                               | FULL                                            |
| binlog_row_metadata                            | MINIMAL                                         |
| binlog_row_value_options                       |                                                 |
| binlog_rows_query_log_events                   | OFF                                             |
| binlog_stmt_cache_size                         | 32768                                           |
| binlog_transaction_compression                 | OFF                                             |
| binlog_transaction_compression_level_zstd      | 3                                               |
| binlog_transaction_dependency_history_size     | 25000                                           |
| binlog_transaction_dependency_tracking         | COMMIT_ORDER                                    |
| expire_logs_days                               | 0                                               |
| general_log                                    | ON                                              |
| general_log_file                               | query.log                                       |
| innodb_api_enable_binlog                       | OFF                                             |
| innodb_flush_log_at_timeout                    | 1                                               |
| innodb_flush_log_at_trx_commit                 | 1                                               |
| innodb_log_buffer_size                         | 16777216                                        |
| innodb_log_checksums                           | ON                                              |
| innodb_log_compressed_pages                    | ON                                              |
| innodb_log_file_size                           | 50331648                                        |
| innodb_log_files_in_group                      | 2                                               |
| innodb_log_group_home_dir                      | ./                                              |
| innodb_log_spin_cpu_abs_lwm                    | 80                                              |
| innodb_log_spin_cpu_pct_hwm                    | 50                                              |
| innodb_log_wait_for_flush_spin_hwm             | 400                                             |
| innodb_log_write_ahead_size                    | 8192                                            |
| innodb_log_writer_threads                      | ON                                              |
| innodb_max_undo_log_size                       | 1073741824                                      |
| innodb_online_alter_log_max_size               | 134217728                                       |
| innodb_print_ddl_logs                          | OFF                                             |
| innodb_redo_log_archive_dirs                   |                                                 |
| innodb_redo_log_capacity                       | 104857600                                       |
| innodb_redo_log_encrypt                        | OFF                                             |
| innodb_undo_log_encrypt                        | OFF                                             |
| innodb_undo_log_truncate                       | ON                                              |
| log_bin                                        | ON                                              |
| log_bin_basename                               | /var/lib/mysql/binlog                           |
| log_bin_index                                  | /var/lib/mysql/binlog.index                     |
| log_bin_trust_function_creators                | OFF                                             |
| log_bin_use_v1_row_events                      | OFF                                             |
| log_error                                      | ./error.log                                     |
| log_error_services                             | log_filter_internal; log_sink_internal          |
| log_error_suppression_list                     |                                                 |
| log_error_verbosity                            | 2                                               |
| log_output                                     | FILE                                            |
| log_queries_not_using_indexes                  | OFF                                             |
| log_raw                                        | OFF                                             |
| log_replica_updates                            | ON                                              |
| log_slave_updates                              | ON                                              |
| log_slow_admin_statements                      | OFF                                             |
| log_slow_extra                                 | OFF                                             |
| log_slow_replica_statements                    | OFF                                             |
| log_slow_slave_statements                      | OFF                                             |
| log_statements_unsafe_for_binlog               | ON                                              |
| log_throttle_queries_not_using_indexes         | 0                                               |
| log_timestamps                                 | UTC                                             |
| max_binlog_cache_size                          | 18446744073709547520                            |
| max_binlog_size                                | 104857600                                       |
| max_binlog_stmt_cache_size                     | 18446744073709547520                            |
| max_relay_log_size                             | 0                                               |
| relay_log                                      | ip-172-31-23-108-relay-bin                      |
| relay_log_basename                             | /var/lib/mysql/ip-172-31-23-108-relay-bin       |
| relay_log_index                                | /var/lib/mysql/ip-172-31-23-108-relay-bin.index |
| relay_log_info_file                            | relay-log.info                                  |
| relay_log_info_repository                      | TABLE                                           |
| relay_log_purge                                | ON                                              |
| relay_log_recovery                             | OFF                                             |
| relay_log_space_limit                          | 0                                               |
| slow_query_log                                 | ON                                              |
| slow_query_log_file                            | slow.log                                        |
| sql_log_off                                    | OFF                                             |
| sync_binlog                                    | 1                                               |
| sync_relay_log                                 | 10000                                           |
| sync_relay_log_info                            | 10000                                           |
| terminology_use_previous                       | NONE                                            |
+------------------------------------------------+-------------------------------------------------+
91 rows in set (0.00 sec)

mysql> 
  • mysql の接続を切断し、オプションを変更します。オプションの変更は、mysqld.cnf を編集します。
$ sudo cp /etc/mysql/mysql.conf.d/mysqld.cnf /etc/mysql/mysql.conf.d/mysqld.cnf_20231203
$ sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf
  • 今回、主に log に関する変数を変更しています。general_log_file, general_log, log_error, slow_query_log, slow_query_log_file および character-set-server になります。
  • 編集したmysqld.cnf の内容を確認後、systemctl にて mysql を再起動します。
$ cat /etc/mysql/mysql.conf.d/mysqld.cnf
#
# The MySQL database server configuration file.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

# Here is entries for some specific programs
# The following values assume you have at least 32M ram

[mysqld]
#
# * Basic Settings
#
user            = mysql
# pid-file      = /var/run/mysqld/mysqld.pid
# socket        = /var/run/mysqld/mysqld.sock
# port          = 3306
# datadir       = /var/lib/mysql


# If MySQL is running as a replication slave, this should be
# changed. Ref https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_tmpdir
# tmpdir                = /tmp
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address            = 127.0.0.1
mysqlx-bind-address     = 127.0.0.1
#
# * Fine Tuning
#
key_buffer_size         = 16M
# max_allowed_packet    = 64M
# thread_stack          = 256K

# thread_cache_size       = -1

# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover-options  = BACKUP

# max_connections        = 151

# table_open_cache       = 4000

#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
#
# Log all queries
# Be aware that this log type is a performance killer.
general_log_file        = /var/log/mysql/query.log
general_log             = 1
#
# Error log - should be very few entries.
#
log_error = /var/log/mysql/error.log
#
# Here you can see queries with especially long duration
 slow_query_log         = 1
 slow_query_log_file    = /var/log/mysql/mysql-slow.log
# long_query_time = 2
# log-queries-not-using-indexes
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
#       other settings you may need to change.
# server-id             = 1
# log_bin                       = /var/log/mysql/mysql-bin.log
# binlog_expire_logs_seconds    = 2592000
max_binlog_size   = 100M
# binlog_do_db          = include_database_name
# binlog_ignore_db      = include_database_name
#
character-set-server = utf8
$
$ systemctl status mysql
● mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2023-12-02 16:35:41 UTC; 8min ago
    Process: 2278 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
   Main PID: 2288 (mysqld)
     Status: "Server is operational"
      Tasks: 37 (limit: 2329)
     Memory: 365.0M
        CPU: 3.359s
     CGroup: /system.slice/mysql.service
             └─2288 /usr/sbin/mysqld
$ sudo systemctl restart mysql
$ systemctl status mysql
● mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2023-12-02 16:44:28 UTC; 22s ago
    Process: 2369 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
   Main PID: 2379 (mysqld)
     Status: "Server is operational"
      Tasks: 38 (limit: 2329)
     Memory: 365.1M
        CPU: 1.092s
     CGroup: /system.slice/mysql.service
             └─2379 /usr/sbin/mysqld
$

 

  • MySQL に接続し、再度設定を確認します。SHOW GLOBAL VARIABLES LIKE '%log%’ を実行しています。設定が変更されたことを確認します。
$ mysql -u dbadmin -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.35-0ubuntu0.22.04.1 (Ubuntu)

Copyright (c) 2000, 2023, 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 GLOBAL VARIABLES LIKE '%log%';
+------------------------------------------------+-------------------------------------------------+
| Variable_name                                  | Value                                           |
+------------------------------------------------+-------------------------------------------------+
| activate_all_roles_on_login                    | OFF                                             |
| back_log                                       | 151                                             |
| binlog_cache_size                              | 32768                                           |
| binlog_checksum                                | CRC32                                           |
| binlog_direct_non_transactional_updates        | OFF                                             |
| binlog_encryption                              | OFF                                             |
| binlog_error_action                            | ABORT_SERVER                                    |
| binlog_expire_logs_auto_purge                  | ON                                              |
| binlog_expire_logs_seconds                     | 2592000                                         |
| binlog_format                                  | ROW                                             |
| binlog_group_commit_sync_delay                 | 0                                               |
| binlog_group_commit_sync_no_delay_count        | 0                                               |
| binlog_gtid_simple_recovery                    | ON                                              |
| binlog_max_flush_queue_time                    | 0                                               |
| binlog_order_commits                           | ON                                              |
| binlog_rotate_encryption_master_key_at_startup | OFF                                             |
| binlog_row_event_max_size                      | 8192                                            |
| binlog_row_image                               | FULL                                            |
| binlog_row_metadata                            | MINIMAL                                         |
| binlog_row_value_options                       |                                                 |
| binlog_rows_query_log_events                   | OFF                                             |
| binlog_stmt_cache_size                         | 32768                                           |
| binlog_transaction_compression                 | OFF                                             |
| binlog_transaction_compression_level_zstd      | 3                                               |
| binlog_transaction_dependency_history_size     | 25000                                           |
| binlog_transaction_dependency_tracking         | COMMIT_ORDER                                    |
| expire_logs_days                               | 0                                               |
| general_log                                    | ON                                              |
| general_log_file                               | /var/log/mysql/query.log                        |
| innodb_api_enable_binlog                       | OFF                                             |
| innodb_flush_log_at_timeout                    | 1                                               |
| innodb_flush_log_at_trx_commit                 | 1                                               |
| innodb_log_buffer_size                         | 16777216                                        |
| innodb_log_checksums                           | ON                                              |
| innodb_log_compressed_pages                    | ON                                              |
| innodb_log_file_size                           | 50331648                                        |
| innodb_log_files_in_group                      | 2                                               |
| innodb_log_group_home_dir                      | ./                                              |
| innodb_log_spin_cpu_abs_lwm                    | 80                                              |
| innodb_log_spin_cpu_pct_hwm                    | 50                                              |
| innodb_log_wait_for_flush_spin_hwm             | 400                                             |
| innodb_log_write_ahead_size                    | 8192                                            |
| innodb_log_writer_threads                      | ON                                              |
| innodb_max_undo_log_size                       | 1073741824                                      |
| innodb_online_alter_log_max_size               | 134217728                                       |
| innodb_print_ddl_logs                          | OFF                                             |
| innodb_redo_log_archive_dirs                   |                                                 |
| innodb_redo_log_capacity                       | 104857600                                       |
| innodb_redo_log_encrypt                        | OFF                                             |
| innodb_undo_log_encrypt                        | OFF                                             |
| innodb_undo_log_truncate                       | ON                                              |
| log_bin                                        | ON                                              |
| log_bin_basename                               | /var/lib/mysql/binlog                           |
| log_bin_index                                  | /var/lib/mysql/binlog.index                     |
| log_bin_trust_function_creators                | OFF                                             |
| log_bin_use_v1_row_events                      | OFF                                             |
| log_error                                      | /var/log/mysql/error.log                        |
| log_error_services                             | log_filter_internal; log_sink_internal          |
| log_error_suppression_list                     |                                                 |
| log_error_verbosity                            | 2                                               |
| log_output                                     | FILE                                            |
| log_queries_not_using_indexes                  | OFF                                             |
| log_raw                                        | OFF                                             |
| log_replica_updates                            | ON                                              |
| log_slave_updates                              | ON                                              |
| log_slow_admin_statements                      | OFF                                             |
| log_slow_extra                                 | OFF                                             |
| log_slow_replica_statements                    | OFF                                             |
| log_slow_slave_statements                      | OFF                                             |
| log_statements_unsafe_for_binlog               | ON                                              |
| log_throttle_queries_not_using_indexes         | 0                                               |
| log_timestamps                                 | UTC                                             |
| max_binlog_cache_size                          | 18446744073709547520                            |
| max_binlog_size                                | 104857600                                       |
| max_binlog_stmt_cache_size                     | 18446744073709547520                            |
| max_relay_log_size                             | 0                                               |
| relay_log                                      | ip-172-31-23-108-relay-bin                      |
| relay_log_basename                             | /var/lib/mysql/ip-172-31-23-108-relay-bin       |
| relay_log_index                                | /var/lib/mysql/ip-172-31-23-108-relay-bin.index |
| relay_log_info_file                            | relay-log.info                                  |
| relay_log_info_repository                      | TABLE                                           |
| relay_log_purge                                | ON                                              |
| relay_log_recovery                             | OFF                                             |
| relay_log_space_limit                          | 0                                               |
| slow_query_log                                 | ON                                              |
| slow_query_log_file                            | /var/log/mysql/mysql-slow.log                   |
| sql_log_off                                    | OFF                                             |
| sync_binlog                                    | 1                                               |
| sync_relay_log                                 | 10000                                           |
| sync_relay_log_info                            | 10000                                           |
| terminology_use_previous                       | NONE                                            |
+------------------------------------------------+-------------------------------------------------+
91 rows in set (0.00 sec)

mysql> SHOW GLOBAL VARIABLES LIKE '%char%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8mb3                    |
| character_set_connection | utf8mb3                    |
| character_set_database   | utf8mb3                    |
| character_set_filesystem | binary                     |
| character_set_results    | utf8mb3                    |
| character_set_server     | utf8mb3                    |
| character_set_system     | utf8mb3                    |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)

mysql> exit
Bye
$

 

ハマったこと

  • 先ず1つ目にハマったことは、オプション設定のファイルが分かっていなかったため、/etc/mysql/my.cnf を変更しても設定が反映されなかったことです。
  • 2つ目にハマったことは、設定したつもりになって以下のエラーが出力されたことです。このファイル (/etc/mysql/conf.d/mysql.cnf) は、MySQL のクライアント設定であり間違いでした。MySQL のサーバーのファイル (/etc/mysql/mysql.conf.d/mysqld.cnf) に設定を行い反映されました。
    • mysql: [ERROR] unknown variable 'log_error=/var/log/mysql/error.log’.

 

関連資料