in Configurator/Core/Server/MySqlServerSettings.cs [1159:1270]
private void LoadIniSettings()
{
Logger.LogInformation("Server Settings - Load Ini Settings - find existing config file");
FindConfigFile();
if (string.IsNullOrEmpty(IniDirectory))
{
return;
}
// Assign to a variable to avoid recomputing the full path over and over
var fullIniPath = FullConfigFilePath;
// TODO: Review this if, only affects after a new server product is installed, because there is no exists any inifile
if (!File.Exists(fullIniPath))
{
Logger.LogInformation("Server Settings - Load Ini Settings - Loading default settings");
LoadIniDefaults();
}
else
{
Logger.LogInformation("Server Settings - Load Ini Settings - loading IniFileEngine");
var iniFile = new IniFileEngine(fullIniPath).Load();
Logger.LogInformation("Server Settings - Load Ini Settings - IniTemplate Parsing");
var t = new IniTemplate(ServerInstallation.Version, ServerInstallationType);
t.ParseConfigurationFile(fullIniPath);
Logger.LogInformation("Server Settings - Load Ini Settings - getting settings from IniTemplate");
EnableTcpIp = t.EnableNetworking;
Port = t.Port;
DefaultAuthenticationPlugin = DefaultServerAuthenticationPlugin;
EnableNamedPipe = t.EnableNamedPipe;
PipeName = t.PipeName;
EnableSharedMemory = t.EnableSharedMemory;
SharedMemoryName = t.MemoryName;
ServerId = t.ServerId;
NamedPipeFullAccessGroup = t.NamedPipeFullAccessGroup;
Logger.LogInformation("Server Settings - Load Ini Settings - getting settings from IniFileEngine");
// Attempt to read the server installation type from the ini file for old configurations.
// Value is ignored if the extended settings file already contains an entry for the server installation type.
var serverType = iniFile.FindValue<int>("mysql", "server_type", true);
if (serverType != 0)
{
ServerInstallationType = serverType == 1
? ServerInstallationType.Dedicated
: serverType == 2
? ServerInstallationType.Server
: serverType == 3
? ServerInstallationType.Developer
: serverType == 4
? ServerInstallationType.Manual
: ServerInstallationType.Developer;
}
OpenFirewall = EnableTcpIp && IsRuleEnabled(Port.ToString());
ErrorLogFileName = iniFile.FindValue("mysqld", "log-error", false);
EnableGeneralLog = iniFile.FindValue<bool>("mysqld", "general-log", false);
GeneralQueryLogFileName = iniFile.FindValue("mysqld", "general_log_file", false);
EnableSlowQueryLog = iniFile.FindValue<bool>("mysqld", "slow-query-log", false);
SlowQueryLogFileName = iniFile.FindValue("mysqld", "slow_query_log_file", false);
LongQueryTime = iniFile.FindValue<int>("mysqld", "long_query_time", false);
BinLogFileNameBase = iniFile.FindValue("mysqld", "log-bin", false);
EnableBinLog = !string.IsNullOrEmpty(BinLogFileNameBase);
string serverIdValue = iniFile.FindValue<string>("mysqld", "server-id", false);
bool convertResult = UInt32.TryParse(serverIdValue, out var serverId);
ServerId = convertResult ? serverId : (uint?)null;
LowerCaseTableNames = (LowerCaseTableNamesTypes) iniFile.FindValue<int>("mysqld", "lower_case_table_names", false);
var queryCacheSizeConfigTuple = iniFile.FindValueWithState("mysqld", "query_cache_size");
EnableQueryCacheSize = queryCacheSizeConfigTuple.Item1 != ConfigurationKeyType.NotPresent
&& queryCacheSizeConfigTuple.Item1 == ConfigurationKeyType.NotCommented;
var queryCacheTypeConfigTuple = iniFile.FindValueWithState("mysqld", "query_cache_type");
EnableQueryCacheType = queryCacheTypeConfigTuple.Item1 != ConfigurationKeyType.NotPresent
&& queryCacheTypeConfigTuple.Item1 == ConfigurationKeyType.NotCommented;
AuthenticationPolicy = iniFile.FindValue("mysqld", "authentication_policy", false);
DefaultAuthenticationPlugin = ParseFirstFactorAuthentication(AuthenticationPolicy);
SecureFilePrivFolder = iniFile.FindValue("mysqld", "secure-file-priv", false);
// Ensure that if the current ini file doesn't have a value set, then use the default
VerifySecureFilePrivFolder();
MySqlXPort = iniFile.FindValue<uint>("mysqld", "loose_mysqlx_port", false);
if (MySqlXPort == 0)
{
MySqlXPort = iniFile.FindValue<uint>("mysqld", "mysqlx_port", false);
}
var pluginLoad = iniFile.FindValue("mysqld", "plugin_load", false);
Plugins.LoadFromIniFile(pluginLoad);
Plugins.Enable("mysql_firewall", EnterpriseFirewallEnabled);
var serverConfigurationController = ServerInstallation.Controller;
OpenFirewallForXProtocol = serverConfigurationController != null
? serverConfigurationController.ServerVersion.ServerSupportsXProtocol()
: false;
var dataDirectory = iniFile.FindValue("mysqld", "datadir", false);
if (!string.IsNullOrEmpty(dataDirectory)
&& Directory.Exists(dataDirectory))
{
var parentDirectory = Directory.GetParent(dataDirectory);
DataDirectory = parentDirectory != null
? parentDirectory.FullName
: dataDirectory;
}
}
LoadGeneralSettings();
}