From 930563ce0d47dfb80b8298df883030bd3694198b Mon Sep 17 00:00:00 2001 From: Javier Sánchez Parra Date: Wed, 1 Apr 2020 13:53:27 +0200 Subject: #941 Set MySQL encoding to UTF-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit sets the MySQL enconding to UTF8. This way we can avoid problems with special characters in strings, like: ó. It also changes the installation script to always copy the MySQL configuration template and restart MySQL. So, even if the server had MySQL installed before the OpenGnsys installation, the script configures MySQL. Example error that this commit should fix: ogAdmServer[12524]: failed to query database (actualizaSoftware:2380) 1366: Incorrect string value: '\xF3n de ...' for column 'descripcion' at row 1 The encoding configuration before this commit should be like this: mysql> SHOW VARIABLES LIKE 'char%'; +--------------------------+----------------------------+ | Variable_name | Value | +--------------------------+----------------------------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | latin1 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | latin1 | | character_set_system | utf8 | | character_sets_dir | /usr/share/mysql/charsets/ | +--------------------------+----------------------------+ 8 rows in set (0.10 sec) The encoding configuration after this commit should be like this: mysql> SHOW VARIABLES LIKE 'char%'; +--------------------------+----------------------------+ | Variable_name | Value | +--------------------------+----------------------------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | utf8 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | utf8 | | character_set_system | utf8 | | character_sets_dir | /usr/share/mysql/charsets/ | +--------------------------+----------------------------+ 8 rows in set (0.01 sec) --- installer/opengnsys_installer.sh | 23 ++++++++++++----------- server/etc/mysqld-og.cnf | 3 ++- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/installer/opengnsys_installer.sh b/installer/opengnsys_installer.sh index 04807ec4..529f4d43 100755 --- a/installer/opengnsys_installer.sh +++ b/installer/opengnsys_installer.sh @@ -1745,17 +1745,6 @@ INSTVERSION=$(jq -r '.version' $INSTALL_TARGET/doc/VERSION.json) # Instalar base de datos de OpenGnsys Admin. isInArray notinstalled "mysql-server" || isInArray notinstalled "mariadb-server" if [ $? -eq 0 ]; then - # Copiar plantilla de configuración de MySQL. - cp $WORKDIR/opengnsys/server/etc/mysqld-og.cnf $MYSQLCFGDIR 2>/dev/null - # Habilitar gestor de base de datos (MySQL, si falla, MariaDB). - service=$MYSQLSERV - $ENABLESERVICE - if [ $? != 0 ]; then - service=$MARIADBSERV - $ENABLESERVICE - fi - # Activar gestor de base de datos. - $STARTSERVICE # Asignar clave del usuario "root". mysqlSetRootPassword "${MYSQL_ROOT_PASSWORD}" else @@ -1763,6 +1752,18 @@ else mysqlGetRootPassword fi +# Copy MySQL configuration template +cp $WORKDIR/opengnsys/server/etc/mysqld-og.cnf $MYSQLCFGDIR 2>/dev/null +# Enable database manager (MySQL, if missing, MariaDB). +service=$MYSQLSERV +$ENABLESERVICE +if [ $? != 0 ]; then + service=$MARIADBSERV + $ENABLESERVICE +fi +# Activar gestor de base de datos. +$STARTSERVICE + mysqlTestConnection "${MYSQL_ROOT_PASSWORD}" if [ $? -ne 0 ]; then errorAndLog "Error while connection to mysql" diff --git a/server/etc/mysqld-og.cnf b/server/etc/mysqld-og.cnf index b7ea14c0..36641c65 100644 --- a/server/etc/mysqld-og.cnf +++ b/server/etc/mysqld-og.cnf @@ -1,3 +1,4 @@ [mysqld] event_scheduler = ON - +character-set-server=utf8 +collation-server=utf8_general_ci -- cgit v1.2.3-18-g5258