From 6009bba339b200abdec39cf73eefee633ba9cfde Mon Sep 17 00:00:00 2001 From: ColorfullyZhang <36832299+ColorfullyZhang@users.noreply.github.com> Date: Thu, 16 Sep 2021 14:41:24 +0800 Subject: [PATCH 1/2] Set mysql character set to utf8 explicitly to support chinese characters (or other special characters). --- src/zm_db.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/zm_db.cpp b/src/zm_db.cpp index 0d499edbd..c6cc452b9 100644 --- a/src/zm_db.cpp +++ b/src/zm_db.cpp @@ -102,6 +102,7 @@ bool zmDbConnect() { if ( mysql_query(&dbconn, "SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED") ) { Error("Can't set isolation level: %s", mysql_error(&dbconn)); } + mysql_set_character_set(&dbconn, "utf8"); zmDbConnected = true; return zmDbConnected; } From f5d8eaa2ad7253634994f3d6ffbc94cee8772aa7 Mon Sep 17 00:00:00 2001 From: ColorfullyZhang <36832299+ColorfullyZhang@users.noreply.github.com> Date: Thu, 16 Sep 2021 18:24:37 +0800 Subject: [PATCH 2/2] Set character set as utf8 when connect to mysql to avoid mistakes when there are Chinese characters in storage path. --- scripts/ZoneMinder/lib/ZoneMinder/Database.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Database.pm b/scripts/ZoneMinder/lib/ZoneMinder/Database.pm index 18df301f3..35d2dc6fa 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Database.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Database.pm @@ -107,6 +107,7 @@ sub zmDbConnect { .$socket . $sslOptions . ($options?join(';', '', map { $_.'='.$$options{$_} } keys %{$options} ) : '') , $ZoneMinder::Config::Config{ZM_DB_USER} , $ZoneMinder::Config::Config{ZM_DB_PASS} + , { mysql_enable_utf8 => 1, } ); }; if ( !$dbh or $@ ) {