From 5babe3dce66d6dcce0b15eda7a24b63b70668069 Mon Sep 17 00:00:00 2001 From: Thatoo Date: Thu, 16 May 2024 22:35:10 +0200 Subject: [PATCH 1/2] Update ynh_mysql_connect_as in mysql helper Update ynh_mysql_connect_as() helper to be able, when restoring a database, to specify --default-character-set="xxx", xxx being latin1 or utf8mb4 --- helpers/mysql | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/helpers/mysql b/helpers/mysql index c11f7989a2..94179f2fd6 100644 --- a/helpers/mysql +++ b/helpers/mysql @@ -14,16 +14,25 @@ # Requires YunoHost version 2.2.4 or higher. ynh_mysql_connect_as() { # Declare an array to define the options of this helper. - local legacy_args=upd - local -A args_array=([u]=user= [p]=password= [d]=database=) + local legacy_args=updc + local -A args_array=( [u]=user= [p]=password= [d]=database= [c]=default_character_set= ) local user local password local database + local default_character_set # Manage arguments with getopts ynh_handle_getopts_args "$@" database="${database:-}" + default_character_set="${default_character_set:-}" - mysql --user="$user" --password="$password" --batch "$database" + if [ -n "$default_character_set" ] + then + default_character_set="--default-character-set=$default_character_set" + else + default_character_set="--default-character-set=latin1" + fi + + mysql --user="$user" --password="$password" "$default_character_set" --batch "$database" } # Execute a command as root user From 85d5ed12849bca6aba503b11139b944cfbd53fd7 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com> Date: Sun, 19 May 2024 15:46:58 +0200 Subject: [PATCH 2/2] Update mysql: add default_character_set option to ynh_mysql_dump_db --- helpers/mysql | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/helpers/mysql b/helpers/mysql index 94179f2fd6..e4bcb42f63 100644 --- a/helpers/mysql +++ b/helpers/mysql @@ -136,13 +136,15 @@ ynh_mysql_drop_db() { # Requires YunoHost version 2.2.4 or higher. ynh_mysql_dump_db() { # Declare an array to define the options of this helper. - local legacy_args=d - local -A args_array=([d]=database=) + local legacy_args=dc + local -A args_array=( [d]=database= [c]=default_character_set= ) local database + local default_character_set # Manage arguments with getopts ynh_handle_getopts_args "$@" + default_character_set="${default_character_set:-latin1}" - mysqldump --single-transaction --skip-dump-date --routines "$database" + mysqldump --single-transaction --skip-dump-date --routines --default-character-set=$default_character_set "$database" } # Create a user