1
1
/*
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.
3
3
4
4
This program is free software; you can redistribute it and/or modify
5
5
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)
182
182
183
183
if (setup == 2 || config.m_generated )
184
184
{
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
+ }
185
200
/* *
186
201
* Do mysql_install_db
187
202
*/
@@ -197,26 +212,63 @@ setup_files(atrt_config& config, int setup, int sshx)
197
212
const char * val;
198
213
require (proc.m_options .m_loaded .get (" --datadir=" , &val));
199
214
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
+ }
203
236
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
+ }
215
266
}
216
267
#else
217
268
{
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 ());
220
272
}
221
273
#endif
222
274
}
0 commit comments