MySQL 9.1.0
Source Code Documentation
sql_initialize.cc File Reference
#include "sql/sql_initialize.h"
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "my_dir.h"
#include "my_inttypes.h"
#include "my_io.h"
#include "my_rnd.h"
#include "my_sys.h"
#include "mysql/components/services/log_builtins.h"
#include "mysql/my_loglevel.h"
#include "mysql/strings/m_ctype.h"
#include "mysqld_error.h"
#include "scripts/sql_commands_help_data.h"
#include "scripts/sql_commands_system_data.h"
#include "scripts/sql_commands_system_tables.h"
#include "scripts/sql_commands_system_users.h"
#include "scripts/sys_schema/sql_commands.h"
#include "sql/mysqld.h"
#include "sql/server_component/log_builtins_filter_imp.h"
#include "sql/sql_bootstrap.h"

Macros

#define INSERT_USER_CMD    "CREATE USER root@localhost IDENTIFIED BY '%s' PASSWORD EXPIRE;\n"
 
#define INSERT_USER_CMD_INSECURE   "CREATE USER root@localhost;\n"
 
#define GENERATED_PASSWORD_LENGTH   12
 
#define rnd_of(x)   x[((int)(my_rnd_ssl(&failed) * 100)) % (sizeof(x) - 1)]
 

Functions

bool generate_password (char *password, int size)
 
bool initialize_create_data_directory (const char *data_home)
 Create the data directory. More...
 

Variables

static const char * initialization_cmds [] = {"USE mysql;\n", nullptr}
 
char insert_user_buffer [sizeof(INSERT_USER_CMD)+GENERATED_PASSWORD_LENGTH *2]
 
bool opt_initialize_insecure = false
 
bool mysql_initialize_directory_freshly_created = false
 True if –initialize has actually created the directory. More...
 
static const char * initialization_data []
 
static const char ** cmds []
 
static const char * cmd_descs []
 keep in sync with the above array More...
 

Macro Definition Documentation

◆ GENERATED_PASSWORD_LENGTH

#define GENERATED_PASSWORD_LENGTH   12

◆ INSERT_USER_CMD

#define INSERT_USER_CMD    "CREATE USER root@localhost IDENTIFIED BY '%s' PASSWORD EXPIRE;\n"

◆ INSERT_USER_CMD_INSECURE

#define INSERT_USER_CMD_INSECURE   "CREATE USER root@localhost;\n"

◆ rnd_of

#define rnd_of (   x)    x[((int)(my_rnd_ssl(&failed) * 100)) % (sizeof(x) - 1)]

Function Documentation

◆ generate_password()

bool generate_password ( char *  password,
int  size 
)

◆ initialize_create_data_directory()

bool initialize_create_data_directory ( const char *  data_home)

Create the data directory.

Creates the data directory when –initialize is specified. The directory is created when it does not exist. If it exists, is empty and the process can write into it no action is taken and the directory is accepted. Otherwise an error is thrown.

Parameters
data_homethe normalized path to the data directory
Returns
status
Return values
truefailed to create. Error printed.
falsesuccess

Variable Documentation

◆ cmd_descs

const char* cmd_descs[]
static
Initial value:
= {
"Creating the system database",
"Creating the system tables",
"Filling in the system tables, part 1",
"Filling in the system tables, part 2",
"Filling in the mysql.help table",
"Creating the system users for internal usage",
"Creating the sys schema",
nullptr}

keep in sync with the above array

◆ cmds

const char** cmds[]
static
Initial value:
= {initialization_cmds, mysql_system_tables,
initialization_data, mysql_system_data,
fill_help_tables, mysql_system_users,
mysql_sys_schema, nullptr}
const char * fill_help_tables[]
const char * mysql_sys_schema[]
static const char * initialization_cmds[]
Definition: sql_initialize.cc:50
static const char * initialization_data[]
Definition: sql_initialize.cc:64

◆ initialization_cmds

const char* initialization_cmds[] = {"USE mysql;\n", nullptr}
static

◆ initialization_data

const char* initialization_data[]
static
Initial value:
= {
"FLUSH PRIVILEGES",
"GRANT ALL PRIVILEGES ON *.* TO root@localhost WITH GRANT OPTION;\n",
"GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION;\n",
"INSERT IGNORE INTO mysql.global_grants VALUES ('root', 'localhost', "
"'AUDIT_ABORT_EXEMPT', 'Y');\n",
"INSERT IGNORE INTO mysql.global_grants VALUES ('root', 'localhost', "
"'FIREWALL_EXEMPT', 'Y')",
nullptr}
char insert_user_buffer[sizeof(INSERT_USER_CMD)+GENERATED_PASSWORD_LENGTH *2]
Definition: sql_initialize.cc:58

◆ insert_user_buffer

char insert_user_buffer[sizeof(INSERT_USER_CMD)+GENERATED_PASSWORD_LENGTH *2]

◆ mysql_initialize_directory_freshly_created

bool mysql_initialize_directory_freshly_created = false

True if –initialize has actually created the directory.

◆ opt_initialize_insecure

bool opt_initialize_insecure = false