Skip to content

Commit ad67aac

Browse files
committed
atrt use mysqld --initialize-insecure if possible
mysql_install_db program is removed in newer versions of MySQL. Support for calling mysql_install_db is kept since it should also be able to run with old versions od MySQL which have mysql_install_db program but not --initialize-insecure option for mysqld.
1 parent 1b175b3 commit ad67aac

File tree

2 files changed

+70
-18
lines changed

2 files changed

+70
-18
lines changed

storage/ndb/test/run-test/autotest-run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
##############
2727

2828
save_args=$*
29-
VERSION="autotest-run.sh version 1.06"
29+
VERSION="autotest-run.sh version 1.07"
3030

3131
DATE=`date '+%Y-%m-%d'`
3232
if [ `uname -s` != "SunOS" ]

storage/ndb/test/run-test/files.cpp

Lines changed: 69 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -182,6 +182,21 @@ setup_files(atrt_config& config, int setup, int sshx)
182182

183183
if (setup == 2 || config.m_generated)
184184
{
185+
bool use_mysqld = false;
186+
{
187+
BaseString tmp;
188+
tmp.assfmt("%s --help --verbose", g_mysqld_bin_path);
189+
FILE *f = popen(tmp.c_str(), "re");
190+
char buf[1000];
191+
while (NULL != fgets(buf, sizeof(buf), f))
192+
{
193+
if (strncmp(buf, "initialize-insecure ", 20) == 0)
194+
{
195+
use_mysqld = true;
196+
}
197+
}
198+
pclose(f);
199+
}
185200
/**
186201
* Do mysql_install_db
187202
*/
@@ -197,26 +212,63 @@ setup_files(atrt_config& config, int setup, int sshx)
197212
const char * val;
198213
require(proc.m_options.m_loaded.get("--datadir=", &val));
199214
BaseString tmp;
200-
tmp.assfmt("%s --defaults-file=%s/my.cnf --basedir=%s --datadir=%s > %s/mysql_install_db.log 2>&1",
201-
g_mysql_install_db_bin_path, g_basedir, g_prefix0, val, proc.m_proc.m_cwd.c_str());
202-
215+
if (use_mysqld)
216+
{
217+
tmp.assfmt("%s --defaults-file=%s/my.cnf --basedir=%s "
218+
"--datadir=%s --initialize-insecure "
219+
"> %s/mysqld-initialize.log 2>&1",
220+
g_mysqld_bin_path,
221+
g_basedir,
222+
g_prefix,
223+
val,
224+
proc.m_proc.m_cwd.c_str());
225+
}
226+
else
227+
{
228+
tmp.assfmt("%s --defaults-file=%s/my.cnf --basedir=%s "
229+
"--datadir=%s > %s/mysql_install_db.log 2>&1",
230+
g_mysql_install_db_bin_path,
231+
g_basedir,
232+
g_prefix0,
233+
val,
234+
proc.m_proc.m_cwd.c_str());
235+
}
203236
to_fwd_slashes(tmp);
204-
if (sh(tmp.c_str()) != 0)
205-
{
206-
g_logger.error("Failed to mysql_install_db for %s, cmd: '%s'",
207-
proc.m_proc.m_cwd.c_str(),
208-
tmp.c_str());
209-
}
210-
else
211-
{
212-
g_logger.info("mysql_install_db for %s",
213-
proc.m_proc.m_cwd.c_str());
214-
}
237+
if (sh(tmp.c_str()) != 0)
238+
{
239+
if (use_mysqld)
240+
{
241+
g_logger.error("Failed to mysqld --initialize-insecure for "
242+
"%s, cmd: '%s'",
243+
proc.m_proc.m_cwd.c_str(),
244+
tmp.c_str());
245+
}
246+
else
247+
{
248+
g_logger.error("Failed to mysql_install_db for %s, cmd: '%s'",
249+
proc.m_proc.m_cwd.c_str(),
250+
tmp.c_str());
251+
}
252+
}
253+
else
254+
{
255+
if (use_mysqld)
256+
{
257+
g_logger.info("mysqld --initialize-insecure for %s",
258+
proc.m_proc.m_cwd.c_str());
259+
}
260+
else
261+
{
262+
g_logger.info("mysql_install_db for %s",
263+
proc.m_proc.m_cwd.c_str());
264+
}
265+
}
215266
}
216267
#else
217268
{
218-
g_logger.info("not running mysql_install_db for %s",
219-
proc.m_proc.m_cwd.c_str());
269+
g_logger.info("not running mysqld --initialize-insecure nor "
270+
"mysql_install_db for %s",
271+
proc.m_proc.m_cwd.c_str());
220272
}
221273
#endif
222274
}

0 commit comments

Comments
 (0)