UTF-8からUTF-8の4バイト

かなーり古いバージョンから引きずってバージョンアップしてきた為、データベースのキャラセット変更です。きっかけとしては NextCloud のワーニング表示。Windowsのファイル名に関連するのかわからないが、毎度出てくるので変更です。

mysql>  show variables like 'innodb_file_format';
+--------------------+----------+
| Variable_name      | Value    |
+--------------------+----------+
| innodb_file_format | Antelope |
+--------------------+----------+
mysql> SET GLOBAL innodb_file_format=Barracuda;
Query OK, 0 rows affected (0.01 sec)

まずは、データベースの InnoDB のフォーマットを Anteloope から Barracuda にオンライン変更。当然事前バックアップ済み。

mysql> show variables like 'innodb_file_format';
+--------------------+-----------+
| Variable_name      | Value     |
+--------------------+-----------+
| innodb_file_format | Barracuda |
+--------------------+-----------+
1 row in set (0.00 sec)

my.cnf の [mysqld] へ innodb_file_per_table=1とinnodb_file_format = Barracudaを追加して再起動。って、先のオンライン変更の意味があったかは不明だが。

その後は、単一データベース nextcloud のキャラセットを utf8mb4 へ変更。

mysql> ALTER DATABASE nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
Query OK, 1 row affected (0.02 sec)

NextCloud の occ で変換実行。エラーがでてビビりました。

$ sudo -u apache php ./occ config:system:set mysql.utf8mb4 --type boolean --value="true"

System config value mysql.utf8mb4 set to boolean true



$ sudo -u apache php ./occ maintenance:repair

 - Repair MySQL collation
     - Change row format for oc_accounts ...
     - Change collation for oc_accounts ...
     - Change row format for oc_activity ...
     - Change collation for oc_activity ...
     - Change row format for oc_activity_mq ...
     - Change collation for oc_activity_mq ...
     - Change row format for oc_addressbookchanges ...
     - Change collation for oc_addressbookchanges ...
     - Change row format for oc_addressbooks ...
     - Change collation for oc_addressbooks ...

In AbstractMySQLDriver.php line 106:

  An exception occurred while executing 'ALTER TABLE `oc_addressbooks` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;':

  SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes


In PDOStatement.php line 119:

  SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes


In PDOStatement.php line 117:

  SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes


maintenance:repair [--include-expensive]

my.cnf の [mysqld] へ innodb_large_prefix=true を追加して再実行。


Nextcloud is in maintenance mode - no apps have been loaded

 - Repair MySQL collation
     - Change row format for oc_addressbooks ...
     - Change collation for oc_addressbooks ...
     - Change row format for oc_appconfig ...
     - Change collation for oc_appconfig ...
     - Change row format for oc_authtoken ...
     - Change collation for oc_authtoken ...
     - Change row format for oc_bruteforce_attempts ...
     - Change collation for oc_bruteforce_attempts ...
     - Change row format for oc_calendar_invitations ...
     - Change collation for oc_calendar_invitations ...
     - Change row format for oc_calendar_reminders ...
     - Change collation for oc_calendar_reminders ...
     - Change row format for oc_calendar_resources ...
     - Change collation for oc_calendar_resources ...
     - Change row format for oc_calendar_resources_md ...
     - Change collation for oc_calendar_resources_md ...
     - Change row format for oc_calendar_rooms ...
     - Change collation for oc_calendar_rooms ...
     - Change row format for oc_calendar_rooms_md ...
     - Change collation for oc_calendar_rooms_md ...
     - Change row format for oc_calendarchanges ...
     - Change collation for oc_calendarchanges ...
     - Change row format for oc_calendarobjects ...
     - Change collation for oc_calendarobjects ...
     - Change row format for oc_calendarobjects_props ...
     - Change collation for oc_calendarobjects_props ...
     - Change row format for oc_calendars ...
     - Change collation for oc_calendars ...
     - Change row format for oc_calendarsubscriptions ...
     - Change collation for oc_calendarsubscriptions ...
     - Change row format for oc_cards ...
     - Change collation for oc_cards ...
     - Change row format for oc_cards_properties ...
     - Change collation for oc_cards_properties ...
     - Change row format for oc_collres_accesscache ...
     - Change collation for oc_collres_accesscache ...
     - Change row format for oc_collres_collections ...
     - Change collation for oc_collres_collections ...
     - Change row format for oc_collres_resources ...
     - Change collation for oc_collres_resources ...
     - Change row format for oc_comments ...
     - Change collation for oc_comments ...
     - Change row format for oc_comments_read_markers ...
     - Change collation for oc_comments_read_markers ...
     - Change row format for oc_credentials ...
     - Change collation for oc_credentials ...
     - Change row format for oc_dav_cal_proxy ...
     - Change collation for oc_dav_cal_proxy ...
     - Change row format for oc_dav_shares ...
     - Change collation for oc_dav_shares ...
     - Change row format for oc_directlink ...
     - Change collation for oc_directlink ...
     - Change row format for oc_external_applicable ...
     - Change collation for oc_external_applicable ...
     - Change row format for oc_external_config ...
     - Change collation for oc_external_config ...
     - Change row format for oc_external_mounts ...
     - Change collation for oc_external_mounts ...
     - Change row format for oc_external_options ...
     - Change collation for oc_external_options ...
     - Change row format for oc_file_locks ...
     - Change collation for oc_file_locks ...
     - Change row format for oc_filecache ...
     - Change collation for oc_filecache ...
     - Change row format for oc_filecache_extended ...
     - Change collation for oc_filecache_extended ...
     - Change row format for oc_files_trash ...
     - Change collation for oc_files_trash ...
     - Change row format for oc_flow_checks ...
     - Change collation for oc_flow_checks ...
     - Change row format for oc_flow_operations ...
     - Change collation for oc_flow_operations ...
     - Change row format for oc_group_admin ...
     - Change collation for oc_group_admin ...
     - Change row format for oc_group_user ...
     - Change collation for oc_group_user ...
     - Change row format for oc_groups ...
     - Change collation for oc_groups ...
     - Change row format for oc_jobs ...
     - Change collation for oc_jobs ...
     - Change row format for oc_login_flow_v2 ...
     - Change collation for oc_login_flow_v2 ...
     - Change row format for oc_migrations ...
     - Change collation for oc_migrations ...
     - Change row format for oc_mimetypes ...
     - Change collation for oc_mimetypes ...
     - Change row format for oc_mounts ...
     - Change collation for oc_mounts ...
     - Change row format for oc_notifications ...
     - Change collation for oc_notifications ...
     - Change row format for oc_notifications_pushtokens ...
     - Change collation for oc_notifications_pushtokens ...
     - Change row format for oc_oauth2_access_tokens ...
     - Change collation for oc_oauth2_access_tokens ...
     - Change row format for oc_oauth2_clients ...
     - Change collation for oc_oauth2_clients ...
     - Change row format for oc_preferences ...
     - Change collation for oc_preferences ...
     - Change row format for oc_preview_generation ...
     - Change collation for oc_preview_generation ...
     - Change row format for oc_privacy_admins ...
     - Change collation for oc_privacy_admins ...
     - Change row format for oc_privatedata ...
     - Change collation for oc_privatedata ...
     - Change row format for oc_properties ...
     - Change collation for oc_properties ...
     - Change row format for oc_schedulingobjects ...
     - Change collation for oc_schedulingobjects ...
     - Change row format for oc_share ...
     - Change collation for oc_share ...
     - Change row format for oc_share_external ...
     - Change collation for oc_share_external ...
     - Change row format for oc_storages ...
     - Change collation for oc_storages ...
     - Change row format for oc_systemtag ...
     - Change collation for oc_systemtag ...
     - Change row format for oc_systemtag_group ...
     - Change collation for oc_systemtag_group ...
     - Change row format for oc_systemtag_object_mapping ...
     - Change collation for oc_systemtag_object_mapping ...
     - Change row format for oc_text_documents ...
     - Change collation for oc_text_documents ...
     - Change row format for oc_text_sessions ...
     - Change collation for oc_text_sessions ...
     - Change row format for oc_text_steps ...
     - Change collation for oc_text_steps ...
     - Change row format for oc_trusted_servers ...
     - Change collation for oc_trusted_servers ...
     - Change row format for oc_twofactor_backupcodes ...
     - Change collation for oc_twofactor_backupcodes ...
     - Change row format for oc_twofactor_providers ...
     - Change collation for oc_twofactor_providers ...
     - Change row format for oc_twofactor_totp_secrets ...
     - Change collation for oc_twofactor_totp_secrets ...
     - Change row format for oc_users ...
     - Change collation for oc_users ...
     - Change row format for oc_vcategory ...
     - Change collation for oc_vcategory ...
     - Change row format for oc_vcategory_to_object ...
     - Change collation for oc_vcategory_to_object ...
     - Change row format for oc_whats_new ...
     - Change collation for oc_whats_new ...
     - Change row format for oc_federated_reshares ...
     - Change collation for oc_federated_reshares ...
 - Repair mime types
 - Clean tags and favorites
     - 0 tags of deleted users have been removed.
     - 0 tags for delete files have been removed.
     - 0 tag entries for deleted tags have been removed.
     - 0 tags with no entries have been removed.
 - Repair invalid shares
 - Move .step file of updater to backup location
 - Fix potential broken mount points
     - No mounts updated
 - Add log rotate job
 - Clear frontend caches
     - Image cache cleared
     - SCSS cache cleared
     - JS cache cleared
 - Clear every generated avatar on major updates
 - Add preview background cleanup job
 - Queue a one-time job to cleanup old backups of the updater
 - Cleanup invalid photocache files for carddav
 - Add background job to cleanup login flow v2 tokens
 - Remove potentially over exposing share links
     - No need to remove link shares.
 - Clear access cache of projects
 - Cleanup cypress files from viewer app
 - Switches from deprecated "production" to "stable" update channel
 - Sets the enterprise logo
     - Repair step already executed
 - Fix component of birthday calendars
     - 2 birthday calendars updated.
 - Regenerating birthday calendars to use new icons and fix old birthday events without year
     - Repair step already executed
 - Fix broken values of calendar objects
    0 [>---------------------------]
 - Registering building of calendar search index as background job
     - Repair step already executed
 - Registering background jobs to update cache for webcal calendars
     - Added 0 background jobs to update webcal calendars
 - Registering building of calendar reminder index as background job
     - Repair step already executed
 - Clean up orphan event and contact data
     - 0 events without a calendar have been cleaned up
     - 0 properties without an events have been cleaned up
     - 0 changes without a calendar have been cleaned up
     - 0 cached events without a calendar subscription have been cleaned up
     - 0 changes without a calendar subscription have been cleaned up
     - 0 contacts without an addressbook have been cleaned up
     - 0 properties without a contact have been cleaned up
     - 0 changes without an addressbook have been cleaned up
 - Remove activity entries of private events
     - Removed 0 activity entries
 - Fix the share type of guest shares when migrating from ownCloud
 - Copy the share password into the dedicated column
 - Update OAuth token expiration times
 - Add background job to check for backup codes

無事完了です。これでメンテナンスモードをOFFにして完了。

$ sudo -u apache php ./occ maintenance:mode --off

代わり映えしませんが、メッセージ表示は消えました。

>株式会社シーポイントラボ

株式会社シーポイントラボ

TEL:053-543-9889
営業時間:9:00~18:00(月〜金)
住所:〒432-8003
   静岡県浜松市中央区和地山3-1-7
   浜松イノベーションキューブ 315
※ご来社の際はインターホンで「316」をお呼びください

CTR IMG