Skip to content

Commit 41b0d98

Browse files
committed
MDEV-23067 Windows : manually registered services rejected mysql_upgrade_service
- service not using "--defaults-file" can have any name not just "MySQL" - service with "--defaults-file", without datadir in them use default datadir (install_root\data)
1 parent fe05c16 commit 41b0d98

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

sql/winservice.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,7 @@ int get_mysql_service_properties(const wchar_t *bin_path,
150150
There are rare cases where service config does not have
151151
--defaults-filein the binary parth . There services were registered with
152152
plain mysqld --install, the data directory is next to "bin" in this case.
153-
Service name (second parameter) must be MySQL.
154153
*/
155-
if(wcscmp(args[1], L"MySQL") != 0)
156-
goto end;
157154
have_inifile= FALSE;
158155
}
159156
else if(numargs == 3)
@@ -211,7 +208,7 @@ int get_mysql_service_properties(const wchar_t *bin_path,
211208
}
212209
}
213210

214-
if(!have_inifile)
211+
if(!have_inifile || props->datadir[0] == 0)
215212
{
216213
/*
217214
Hard, although a rare case, we're guessing datadir and defaults-file.
@@ -235,22 +232,25 @@ int get_mysql_service_properties(const wchar_t *bin_path,
235232
*p= 0;
236233
}
237234

238-
/* Look for my.ini, my.cnf in the install root */
239-
sprintf_s(props->inifile, MAX_PATH, "%s\\my.ini", install_root);
240-
if (GetFileAttributes(props->inifile) == INVALID_FILE_ATTRIBUTES)
241-
{
242-
sprintf_s(props->inifile, MAX_PATH, "%s\\my.cnf", install_root);
243-
}
244-
if (GetFileAttributes(props->inifile) != INVALID_FILE_ATTRIBUTES)
245-
{
246-
/* Ini file found, get datadir from there */
247-
GetPrivateProfileString("mysqld", "datadir", NULL, props->datadir,
248-
MAX_PATH, props->inifile);
249-
}
250-
else
235+
if (!have_inifile)
251236
{
252-
/* No ini file */
253-
props->inifile[0]= 0;
237+
/* Look for my.ini, my.cnf in the install root */
238+
sprintf_s(props->inifile, MAX_PATH, "%s\\my.ini", install_root);
239+
if (GetFileAttributes(props->inifile) == INVALID_FILE_ATTRIBUTES)
240+
{
241+
sprintf_s(props->inifile, MAX_PATH, "%s\\my.cnf", install_root);
242+
}
243+
if (GetFileAttributes(props->inifile) != INVALID_FILE_ATTRIBUTES)
244+
{
245+
/* Ini file found, get datadir from there */
246+
GetPrivateProfileString("mysqld", "datadir", NULL, props->datadir,
247+
MAX_PATH, props->inifile);
248+
}
249+
else
250+
{
251+
/* No ini file */
252+
props->inifile[0]= 0;
253+
}
254254
}
255255

256256
/* Try datadir in install directory.*/

0 commit comments

Comments
 (0)