/* Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. Copyright(c)2011,2018,2026MariaDBCorporation Copyright(c)2024,VäinöMäkelä
YoushouldhavereceivedacopyoftheGNUGeneralPublicLicense alongwiththisprogram;ifnot,writetotheFreeSoftware
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
static PSI_memory_key key_memory_upgrade_config; #ifdef HAVE_PSI_FILE_INTERFACE static PSI_file_key key_file_cnf; #endif static size_t global_update_count= 0; static my_bool give_error_for_missing_files= 0; static my_bool opt_mariadbd_testing; staticconstchar *mariadb_replication_compatibility_comment= "# The following options enable MySQL to replicate to MariaDB"; staticconstchar *mysql_replication_compatibility_comment= "# The following options enable MariaDB to replicate to MySQL";
/* Skip over "include / includedir keyword" and following whitespace */
for (ptr+= kwlen - 1;
my_isspace(&my_charset_latin1, ptr[0]);
ptr++)
{}
/* Trimtrailingwhitespacefromdirectoryname The-1belowisforthenewlineaddedbyfgets() Notethatmy_isspace()istruefor\rand\n
*/ for (end= ptr + strlen(ptr) - 1;
my_isspace(&my_charset_latin1, *(end - 1));
end--)
{}
end[0]= 0; /* Cut off end space */
/* Print error msg if there is nothing after !include* directive */ if (end <= ptr)
{
fprintf(stderr, "error: Wrong '!%s' directive in config file: %s at line %d\n",
keyword, name, line); return0;
} return ptr;
}
staticchar *find_end_comment(char *ptr)
{ char quote= 0; /* we are inside quote marks */ char escape= 0; /* symbol is protected by escape chagacter */
for (; *ptr; ptr++)
{ if ((*ptr == '\'' || *ptr == '\"') && !escape)
{ if (!quote)
quote= *ptr; elseif (quote == *ptr)
quote= 0;
} /* We are not inside a string */ if (!quote && *ptr == '#') return ptr;
escape= (quote && *ptr == '\\' && !escape);
} return ptr;
}
struct generator
{ /* the memory root for allocating line strings */
MEM_ROOT alloc; /* array of strings for the main content */
DYNAMIC_ARRAY main; /* arrayofstringsforoptionsthatshouldbeaddedtotheerror_group section
*/
DYNAMIC_ARRAY old_version; /* arrayofstringsforoptionsthatshouldbeaddedtotheunsupported_group section
*/
DYNAMIC_ARRAY unsupported_version; /* array of strings to be added to the mariadbd section */
DYNAMIC_ARRAY mariadbd_additions; /* array of strings to be added to the client_server section */
DYNAMIC_ARRAY client_server;
struct upgrade_ctx *ctx; /* Current context */
constchar *name; /* config file name */ int start_of_group; /* Start of current group */ int mariadbd_group_start; /* Start of last mariadbd group */
uint line; /* Current line number */ /* onepastthelastindexoftheoriginalmariadbdsectioninthemainarray
*/ int mariadbd_group_end; /* the current group from which options are read */ constchar *input_group; /* Thecurrentgroupinthegeneratedoutput.Thismaybedifferentfrom input_groupiflinesaremovedbetweengroups.
*/ char *output_group; /* whether last main line is empty or not */
my_bool prev_empty; /* If we should copy [mysqld-xxx] options to [mariadbd] */
my_bool copy_code_to_mariadb; /* If current file is valid */
my_bool file_valid;
};
staticvoid report_line_changes()
{ if (!opt_print && !opt_silent && opt_edit_mode == EDIT_MODE_NONE)
{ if (global_mariadbd_additions)
fprintf(stdout, "%lld line/lines would be copied to [mariadbd] group\n",
(longlong) global_mariadbd_additions); if (global_copied_lines > 0)
fprintf(stdout, "%lld line/lines would be copied to [%s] group\n",
(longlong) global_copied_lines, opt_error_group); if (global_unsupported_lines)
fprintf(stdout, "%lld line/lines would be copied to [%s] group\n",
(longlong) global_unsupported_lines, opt_unsupported_group);
}
}
if (!opt_print && opt_edit_mode == EDIT_MODE_NONE &&
!generator->copy_code_to_mariadb)
{ if ((renamed= renamed_option(option)))
{ if (value)
fprintf(stdout, "In %s at line %u: '%.*s' would be " "replaced with '%s=%.*s'\n", generator->name, generator->line,
(int) strlen(org_line)-1, org_line, renamed,
(int) strlen(value)-1, value); else
fprintf(stdout, "In %s at line %u: '%.*s' would be " "replaced with '%s'\n", generator->name, generator->line,
(int) strlen(org_line)-1, org_line, renamed);
} else
{
fprintf(stdout, "In %s at line %u: Invalid option %s\n", generator->name,
generator->line, option);
} // ctx->failed= 1;
global_update_count++;
} if (!strncmp(option, STRING_WITH_LEN("audit_log")) &&
!audit_plugin_warning++ && !opt_silent)
fprintf(stdout, "Warning: Please replace audit_log with the server_audit " "plugin\n");
}
/* The string may have an '\n' if paths has changed */ if (!(end= strchr(value, '\n')))
end= strend(value);
value_socket= my_strndup(key_memory_upgrade_config, value, (end-value),
MYF(MY_WME)); return1; /* Socket found */
} return0;
}
/** Writethegivenlinetogeneratoroutputasspecifiedbyopt_edit_mode. Returnsfalseonsuccessandtrueonfailure.
*/ static my_bool generator_add_line(struct generator *generator, constchar *line, enum line_type type, my_bool is_valid)
{ if (generator->copy_code_to_mariadb && is_valid && type != LINE_TYPE_EMPTY)
{ /* Copy lines from [mysqld-XXX] group to [mariadbd] */ constchar *pos= line, *new_line= 0; if (opt_update_paths &&
(new_line= path_changed(generator, line)))
pos= new_line;
add_line(&generator->alloc, &generator->mariadbd_additions, "%s", pos);
my_free((char*) new_line);
} if (generator->copy_code_to_mariadb)
is_valid= 1; /* Print line to [mysqld-XXX] groups */
switch (opt_edit_mode) { case EDIT_MODE_REMOVE:
global_update_count+= MY_TEST(!is_valid); return is_valid ? add_main_line(generator, type, "%s", line) : FALSE; case EDIT_MODE_LAST: if (is_valid || type == LINE_TYPE_EMPTY) return add_main_line(generator, type, "%s", line); if (strcmp(generator->input_group, "mariadbd")) return add_line(&generator->alloc, &generator->old_version, "%s", line); return add_line(&generator->alloc, &generator->unsupported_version, "%s",
line); case EDIT_MODE_COMMENT:
global_update_count+= MY_TEST(!is_valid); return add_main_line(generator, type, is_valid ? "%s" : "#%s", line); case EDIT_MODE_INLINE:
{ constchar *old_input_group= generator->input_group;
my_bool res= TRUE;
global_update_count+= MY_TEST(!is_valid); if (!is_valid)
generator->input_group= (strcmp(generator->input_group, "mariadbd") ?
opt_error_group :
opt_unsupported_group); if (!add_main_line(generator, is_valid ? type : LINE_TYPE_OTHER, "%s",
line))
res= FALSE;
generator->input_group= old_input_group; return res;
} case EDIT_MODE_NONE: return opt_print ? add_main_line(generator, type, "%s", line) : 0;
} returnTRUE;
}
if (opt_print || (opt_edit_mode != EDIT_MODE_NONE && !opt_update))
fprintf(stdout, "### File %s:\n", name); while (mysql_file_fgets(buff, sizeof(buff) - 3, fp))
{
my_bool line_valid= TRUE; int invalid_set_index;
generator.line++; /* Ignore comment and empty lines */ for (ptr= buff; my_isspace(&my_charset_latin1, *ptr); ptr++)
{}
/* Ensure line ends with \n (delete_line code depends one this) */
end= strend(ptr); if (end != ptr && end[-1] != '\n')
{
end[0]= '\n';
end[1]= 0;
}
if (*ptr == '#' || *ptr == ';' || !*ptr)
{ if (is_prefix(ptr, mariadb_replication_compatibility_comment))
{ /* File is already updated */
found_mariadb_replication_compatibility= 0;
} if (is_prefix(ptr, mysql_replication_compatibility_comment))
{ /* File is already updated */
found_mysql_replication_compatibility= 0;
}
generator_add_line(&generator, buff,
*ptr ? LINE_TYPE_OTHER : LINE_TYPE_EMPTY, line_valid); continue;
}
/* Configuration File Directives */ if (*ptr == '!' || *ptr == '?')
{ /* Write out current cached items before include directive */
my_bool prev_empty= generator.prev_empty; if (opt_print || opt_update)
{ if (generator_write(tmp_fp, &generator))
generator.file_valid= FALSE;
} else
generator_count_lines(&generator);
generator_reset(&generator); /* Ensure that when using --print we get !include next */ if (prev_empty && !generator.prev_empty)
generator_add_line(&generator, "\n", LINE_TYPE_EMPTY, 1);
generator_add_line(&generator, buff, LINE_TYPE_PASSTHROUGH, 1);
generator_write(tmp_fp, &generator);
generator_reset(&generator);
if (recursion_level >= max_recursion_level)
{ for (end= ptr + strlen(ptr) - 1;
my_isspace(&my_charset_latin1, *(end - 1));
end--)
{}
end[0]= 0;
fprintf(stderr, "Warning: skipping '%s' directive as maximum include" "recursion level was reached in file %s at line %d\n",
ptr, name, generator.line); continue;
}
/* skip over `!' and following whitespace */ for (++ptr; my_isspace(&my_charset_latin1, ptr[0]); ptr++)
{}
process_default_file_with_ext(ctx, "", "", ptr, recursion_level + 1); if (opt_print || (opt_edit_mode != EDIT_MODE_NONE && !opt_update))
fprintf(stdout, "### Back in %s:\n", name);
} continue;
}
if (*ptr == '[') /* Group name */
{ if (!(end=(char *) strchr(++ptr,']')))
{
fprintf(stderr, "error: Wrong group definition in config file: %s at line %d\n",
name, generator.line); goto err;
} /* Remove end space */ for ( ; my_isspace(&my_charset_latin1,end[-1]) ; end--) ;
end[0]=0;
generator.copy_code_to_mariadb= 0;
found_group= find_type(curr_gr, ctx->group, FIND_TYPE_NO_PREFIX)
? PARSE : SKIP; /* Ensure we process all groups with the mysqld prefix */ if (found_group == SKIP)
{ if (!strncmp(curr_gr, "mysqld-", 7) && opt_copy_mysqld_groups)
{
found_group= PARSE; /* Copy all valid code from the mysqld- group to the mariadbd group */
generator.copy_code_to_mariadb= 1;
}
}
generator.input_group= curr_gr; if (found_group == PARSE && group_is_mariadbd)
{ /** Forcethemariadbdgrouptobeemittedtoallowpotentiallyadding newlinestoit.
*/
generator_add_line(&generator, "", LINE_TYPE_OPTION, TRUE);
} continue;
} switch (found_group) { case NONE:
fprintf(stderr, "error: Found option without preceding group in config " "file: %s at line: %d\n",
name, generator.line); goto err; case PARSE: if (opt_print && opt_edit_mode == EDIT_MODE_NONE)
{
generator_add_line(&generator, buff, LINE_TYPE_OPTION, TRUE); continue;
} break; case SKIP: if (group_is_mariadbd &&
(opt_edit_mode == EDIT_MODE_INLINE ||
opt_edit_mode == EDIT_MODE_LAST))
{ /* Remove lines with the /mysql/ path */ char *pos= change_file_path(buff, &mariadb_name, &mysql_name); if (pos)
{
delete_line(&generator.mariadbd_additions, pos);
my_free(pos);
}
delete_line(&generator.mariadbd_additions, buff);
}
generator_add_line(&generator, buff, LINE_TYPE_OPTION, line_valid); continue;
}
end= end_of_option= find_end_comment(ptr); if ((value= strchr(ptr, '=')) && value < end_of_option)
end= value; else
value= 0;
if (recursion_level == 0)
{ if (found_innodb_log_file_size && found_innodb_log_files_in_group)
{
generator.file_valid= FALSE;
snprintf(conv_option, sizeof(conv_option)-1, "innodb_log_file_size=%llu%c",
value_innodb_log_file_size * value_innodb_log_files_in_group,
(my_islower(&my_charset_latin1, suffix_innodb_log_file_size) ||
my_isupper(&my_charset_latin1, suffix_innodb_log_file_size)) ?
suffix_innodb_log_file_size : ' ');
add_line(&generator.alloc, &generator.mariadbd_additions, "%s\n", conv_option); if (!opt_silent)
fprintf(stdout, "Note: '%s' added to [mariadbd] group based on " "innodb_log_file_size * innodb_log_files_in_group\n", conv_option);
found_innodb_log_file_size= found_innodb_log_files_in_group= 0;
} if (opt_add_client_server_group && !found_client_server_group)
{ if (value_port)
add_line(&generator.alloc, &generator.client_server, "port=%lld\n", value_port); if (value_socket)
{
add_line(&generator.alloc, &generator.client_server, "socket=%s\n", value_socket);
my_free(value_socket);
value_socket= 0;
}
} /* The following options should only be added once */ if (!add_new_options_once || !new_options_added)
{
new_options_added= 1;
/* Add generated options to mariadbd section */ if (opt_add_skip_slave_start && !found_skip_slave_start)
{
generator.file_valid= FALSE;
add_line(&generator.alloc, &generator.mariadbd_additions, "skip_slave_start\n");
found_skip_slave_start= 0;
} if (opt_add_mariadb_replication_compatibility &&
!found_mariadb_replication_compatibility)
{
generator.file_valid= FALSE; /* We do this line by line to get correct row numbers for reporting */
add_line(&generator.alloc, &generator.old_version, "%s\n", mariadb_replication_compatibility_comment);
add_line(&generator.alloc, &generator.old_version, "loose-binlog_row_value_options=\"\"\n");
add_line(&generator.alloc, &generator.old_version, "loose-binlog_transaction_compression=0\n");
add_line(&generator.alloc, &generator.old_version, "# Not required, but recommended for cross_replication\n");
add_line(&generator.alloc, &generator.old_version, "binlog_format=row\n");
} if (opt_add_mysql_replication_compatibility &&
!found_mysql_replication_compatibility)
{
add_line(&generator.alloc, &generator.mariadbd_additions, "%s\n", mysql_replication_compatibility_comment);
add_line(&generator.alloc, &generator.mariadbd_additions, "encrypt_binlog=0\n");
add_line(&generator.alloc, &generator.mariadbd_additions, "log_bin_compress=0\n");
add_line(&generator.alloc, &generator.mariadbd_additions, "# Not required, but recommended for cross_replication\n");
add_line(&generator.alloc, &generator.mariadbd_additions, "binlog_format=row\n"); if (!found_character_set_server)
{
add_line(&generator.alloc, &generator.mariadbd_additions, "# Character set to be able to replicate new tables to " "MySQL 8.0\n");
add_line(&generator.alloc, &generator.mariadbd_additions, "character_set_server=utf8mb4\n");
add_line(&generator.alloc, &generator.mariadbd_additions, "collation_server=utf8mb4_0900_ai_ci\n"); if (!opt_silent)
fprintf(stdout, "Note: Added MySQL default character sets and " "collation to [mariadbd] to be able to replicate to " "MySQL\n");
found_character_set_server= 0;
}
}
}
} if (opt_print || opt_update)
{ if (generator_write(tmp_fp, &generator))
generator.file_valid= 0;
} else
generator_count_lines(&generator);
generator_free(&generator); if (recursion_level == 0)
{
my_free(value_socket);
value_socket= 0;
}
if (tmp_fp)
{
mysql_file_fclose(tmp_fp, MYF(0));
tmp_fp= 0; if (generator.file_valid)
{
my_delete(tmp_name, MYF(0));
} else
{
myf redel_flags = opt_backup ? MYF(MY_REDEL_MAKE_BACKUP) : MYF(0); char *duped_name= my_strdup(key_memory_upgrade_config, name, MYF(0)); if (!duped_name || insert_dynamic(&ctx->updated_files, &duped_name)) goto err; /* Copythefileincaserunningmariadbdfailsandtheupdatemustbe reverted.
*/ if (my_copy(name, restored_name, MYF(0)))
{
fprintf(stderr, "error: Failed to copy %s to %s: %s",
name, restored_name, strerror(errno)); return -1;
} if (my_redel(name, tmp_name, time(NULL), redel_flags))
{
fprintf(stderr, "error: Failed to rename %s to %s: %s",
tmp_name, name, strerror(errno)); return -1;
}
}
} if (opt_print || (opt_edit_mode != EDIT_MODE_NONE && !opt_update))
fputc('\n', stdout); return(0);
err: if (fp)
mysql_file_fclose(fp, MYF(0)); if (tmp_fp)
mysql_file_fclose(tmp_fp, MYF(0)); if (generator_inited)
generator_free(&generator); if (recursion_level == 0)
{
my_free(value_socket);
value_socket= 0;
} return -1; /* Fatal error */
}
if (opt_mariadbd)
used_name= opt_mariadbd; else
{
used_name= mariadbd_name; if (!(error= (find_file_in_path(executable, mariadbd_name) != 0)))
used_name= executable;
} if (!error)
error= access(used_name, X_OK);
if (error)
{
fprintf(stderr, "Cannot execute '%s' to test if the new option files " "works (error %d)\n" "Try specifying the full path for the MariaDB server with " "--mariadbd=...\n",
used_name, (int) errno);
finish_updated_files(&ctx, 1); return1;
}
if (init_dynamic_string(&mariadbd_output, "", 32, 32)) goto err; if (!test_mariadbd(used_name) &&
(error= run_mariadbd(used_name, &mariadbd_output, defaults_args,
defaults_args_count)))
{ if (ctx.updated_files.elements)
fprintf(stderr, "error: Failed to run %s with the updated files, " "reverting\n", used_name); else
fprintf(stderr, "error: Failed to run %s with the original files.\n",
used_name); if (error > 0)
fprintf(stderr, "mariadbd output:\n%s", mariadbd_output.str);
}
dynstr_free(&mariadbd_output);
}
staticstruct my_option my_long_options[] =
{
{"add-skip-slave-start", OPT_ADD_SKIP_SLAVE_START, "Add skip_slave_start to the [mariadbd] group if not present.",
&opt_add_skip_slave_start, &opt_add_skip_slave_start, 0, GET_BOOL, NO_ARG, FALSE, 0, 0, 0, 0, 0},
{"add-mariadb-replication-compatibility",
OPT_ADD_MARIADB_REPLICATION_COMPATIBILITY, "Add options to [error-group] to enable MySQL to replicate to MariaDB. " "Options added are: " "binlog-row-value-options=\"\" binlog_transaction_compression=0 and " "binlog_format=row.",
&opt_add_mariadb_replication_compatibility,
&opt_add_mariadb_replication_compatibility, 0, GET_BOOL, NO_ARG, FALSE, 0, 0, 0, 0, 0},
{"add-mysql-replication-compatibility",
OPT_ADD_MYSQL_REPLICATION_COMPATIBILITY, "Add options to [mariadbd] section to enable MariaDB to replicate to MySQL.",
&opt_add_mysql_replication_compatibility,
&opt_add_mysql_replication_compatibility, 0, GET_BOOL, NO_ARG, FALSE, 0, 0, 0, 0, 0},
{"add-client-server-group",
OPT_ADD_MYSQL_REPLICATION_COMPATIBILITY, "Add a [client-server] group if it does not exists. This will contain the " "last port and socket found in the [mysqld] or [server] groups.",
&opt_add_client_server_group,
&opt_add_client_server_group, 0, GET_BOOL, NO_ARG, FALSE, 0, 0, 0, 0, 0},
{"backup", OPT_BACKUP, "Backup the updated configuration files. The backup file name are of the " "type: 'original_name'-timestamp.BAK",
&opt_backup, &opt_backup, 0, GET_BOOL, NO_ARG, FALSE, 0, 0, 0, 0, 0},
{"copy-mysqld-groups", OPT_COPY_MYSQLD_GROUPS, "Copy valid MariaDB options from [mysqld-###] groups to the [mariadbd] " "group.",
&opt_copy_mysqld_groups, &opt_copy_mysqld_groups, 0, GET_BOOL, NO_ARG, TRUE, 0, 0, 0, 0, 0},
{"error-group", OPT_ERROR_GROUP, "Group to use for options not supported by MariaDB when using " "--edit=[inline|last]. Should be set usually to something like " "'mysqld-#.##' when moving from MySQL and 'unknown' when upgrading " "MariaDB or if there are already [mariadbd] groups in the config files.",
&opt_error_group, &opt_error_group, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"edit", OPT_EDIT, "Select what to do with invalid options. '' (default) no changes. " "'remove' removes them. 'comment' comments them with '#'. " "inline' adds [error_group] before unknown options. " "'last' moves incompatible or mariadbd specific options to the end of " "the given file under [error_group], [unsupported_group] or [mariadbd].",
&opt_edit_mode, &opt_edit_mode, &edit_mode_typelib, GET_ENUM,
REQUIRED_ARG, EDIT_MODE_NONE, 0, 0, 0, 0, 0},
{"fix-all", OPT_FIX_ALL, "Same as --no-myisam --from=mysql --add-skip-slave-start " "--add-mysql-replication-compatibility " "--add-mariadb-replication-compatibility --add-client-server-group " "--edit=last", 0, 0, 0, GET_NO_ARG, NO_ARG, FALSE, 0, 0, 0, 0, 0},
{"from", OPT_CONVERT_FROM, "Options are MySQL (default) or MariaDB. Used to specify if your are " "upgrading from MySQL or an earlier MariaDB version. " "When upgrading from MySQL, only the MySQL groups [mysqld] and [server] " "are processed. If MariaDB is specified, all MariaDB entries read by " "the current MariaDB version (" MYSQL_SERVER_VERSION ") will be processed. " "Note that when upgrading from an earlier MariaDB version, mariadb-upgrade " "is the preferred tool! This tool is in this case mainly useful to check " "if there is any incompatibilities in the MariaDB configuration files.",
&opt_convert_from, &opt_convert_from, &from_mode_typelib, GET_ENUM,
REQUIRED_ARG, FROM_MYSQL, 0, 0, 0, 0, 0},
{"help", '?', "Display this help message and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"mariadbd", OPT_MARIADBD, "Path to the mariadbd server. Used to verify if the config file changes " "succeeded.",
&opt_mariadbd, &opt_mariadbd, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"no-myisam", OPT_NO_MYISAM_OPTIONS, "Assume no usage of MyISAM tables. Makes the MyISAM buffers very small " "to save memory. " "Useful when moving to MariaDB when there are no user data in MyISAM " "tables. This option only has an effect if the config file contains " "settings of the key-buffer-size variable.",
&opt_no_myisam_options, &opt_no_myisam_options, 0, GET_BOOL, NO_ARG, FALSE, 0, 0, 0, 0, 0},
{"print", OPT_PRINT, "Print upgraded files to stdout. The 'edit' option " "decides the output format.",
&opt_print, &opt_print, 0, GET_BOOL, NO_ARG, FALSE, 0, 0, 0, 0, 0},
{"silent", 's', "Print less information",
&opt_silent, &opt_silent, 0, GET_BOOL, NO_ARG, FALSE, 0, 0, 0, 0, 0},
{"update", OPT_UPDATE, "Update the configuration files in place.",
&opt_update, &opt_update, 0, GET_BOOL, NO_ARG, FALSE, 0, 0, 0, 0, 0},
{"update-paths", OPT_UPDATE_PATHS, "When used with --from=mysql, change file paths having /mysql or /mysqld " "ending with '/', '.', space, or new line to /mariadbd. This is intended " "to be used when you want to run MySQL and MariaDB on the same system.",
&opt_update_paths, &opt_update_paths, 0, GET_BOOL, NO_ARG, FALSE, 0, 0, 0, 0, 0},
{"unsupported-group", OPT_UNSUPPORTED_GROUP, "Group to use for options in [mariadbd] group that is not supported by " "MariaDB when using '--edit=[inline|last] --from=mariadb'.",
&opt_unsupported_group, &opt_unsupported_group, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"verify", OPT_VERIFY, "Verify updates by testing the used config files through mariadbd. " "Disabled if --print is used. " "Note that verify only works if one uses --defaults-file=# or if one does " "not specify any configuration files on the command line. " "When using verify the mariadbd option has also to be used.",
&opt_mariadbd_testing, &opt_mariadbd_testing, 0, GET_BOOL, NO_ARG, FALSE, 0, 0, 0, 0, 0},
{"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
staticvoid usage() __attribute__ ((noreturn)); staticvoid usage()
{
print_version();
puts("This software comes with ABSOLUTELY NO WARRANTY. This is free " "software,\nand you are welcome to modify and redistribute it under " "the GPL license\n");
puts("Display or change unrecognized MariaDB options in MariaDB/MySQL\n" "configuration files. This is useful when planning an upgrade from\n" "MySQL to MariaDB or to check if there are some unsupported\n" "options in the option files.\n" "This program can print errors, print the changed files, update the\n" "configuration files in place.\n" "When running with the options:\n" "--update --edit=last --error-group=mysqld-5.7\n" "The configuration files will be changed so that they should work\n" "with both MySQL 5.7 and MariaDB. You should provide the currently\n" "used MySQL version if --error-group is used.\n");
printf("Usage: %s [--print | --update] [OPTIONS] [OPTION_FILES]\n\n",
my_progname);
puts("If OPTION_FILES is not provided, all default MariaDB configuration\n" "files will be printed/upgraded");
puts("");
puts("If moving from MYSQL, the recommended usage is to use the following " "3 steps:");
puts("");
puts("- Check if there is anything that needs changing:");
puts("mariadb-migrate-config-file --from=mysql");
puts("");
puts("- Check how the new configuration files would look like:");
puts("mariadb-migrate-config-file --from=mysql --edit=last --print");
puts("");
puts("- Modify all configuration files keeping backups of the originals:");
puts("mariadb-migrate-config-file --from=mysql --edit=last --update " "--backup --error-group=mysqld-5.7\n");
puts("Examples:");
pe("", "Go through all my.cnf and included files and print not supported " "options. The groups checked are [server], [mysqld] and [mysqld-###]. " "Options valid for MariaDB in [mysqld-###] groups are copied to " "the [mariadbd] group");
pe("--from=mariadb", "Go through all my.cnf and include files and print options not supported " "by the current MariaDB version. All MariaDB groups read by mariadbd are " "checked");
pe("~/.my.cnf", "Print not supported options in ~/.my.cnf");
pe("--defaults-file=/etc/my.cnf --verify=1 --mariadbd=#path-to-mariadbd#", "Go through /etc/my.cnf and print all not supported options. Check also " "the by running it through the MariaDB server");
pe("--print", "Print the current content of all my.cnf and included files " "(no changes)");
pe("--print --edit=last --update-paths", "As print, but change all paths from /mysql to /mariadbd. Useful to " "check the effect of --update-paths");
pe("--print --edit=last", "Print modified version of all my.cnf and included files where supported " "options from [mysqld-###] groups are copied to a [mariadbd] group at " "the end of the file. Not supported options from [mysqld] and [server] " "are moved to [mysqld-5.7] (default value of 'error_group')");
pe("--print --edit=inline --error-group=mysqld-8.0", "Print modified version of all my.cnf and included files where supported " "options from [mysqld-###] groups are copied inline to [mariadbd] " "groups. Not supported options in the [mysqld] and [server] groups are " "moved to [mysqld-8.0]");
pe("--print --edit=remove", "Print modified version of all my.cnf and includedfiles where supported " "options from [mysqld-###] groups are copied to a [mariadbd] group. " "Not supported options from [mysqld] and [server] are removed");
pe("--print --edit=comment", "As '--remove', but not supported options are commented");
pe("--edit=update --edit=inline --backup", "Modify all my.cnf and included files. Supported options from " "[mysqld-###] groups are copied to [mariadbd] groups. Not supported " "options in the [mysqld] and [server] groups are moved to a " "[mysqld-5.7] group. " "The original of the changed config files are stored as backup files. " "If no option files are specified the mariadbd server will be started " "using them to verify that the new options files works with it");
pe("--update --edit=inline --error_group=unknown --from=mariadb", "Move all unknown mariadbd options to the group [unknown]");
pe("--fix-all", "Use all common options when converting from MySQL to MariaDB. " "See definition for --fix-all for more details");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.