MySQL 9.3.0
Source Code Documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
bootstrap_mysql_account.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2022, 2025, Oracle and/or its affiliates.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License, version 2.0,
6 as published by the Free Software Foundation.
7
8 This program is designed to work with certain software (including
9 but not limited to OpenSSL) that is licensed under separate terms,
10 as designated in a particular file or component or in included license
11 documentation. The authors of MySQL hereby grant you an additional
12 permission to link the program and your derivative works with the
13 separately licensed software that they have either included with
14 the program or referenced in the documentation.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24*/
25
26#ifndef ROUTER_SRC_BOOTSTRAP_SRC_BOOTSTRAP_MYSQL_ACCOUNT_H_
27#define ROUTER_SRC_BOOTSTRAP_SRC_BOOTSTRAP_MYSQL_ACCOUNT_H_
28
29#include <map>
30#include <set>
31#include <string>
32
34
35static constexpr unsigned kMaxPasswordRetries = 10000;
36using Strings = std::vector<std::string>;
37
39 std::string account;
41 std::string account_create{"if-not-exists"};
43
45 bool autogenerated{false};
46};
47
49 public:
51
52 std::string create_router_accounts(const UserOptions &user_options,
53 const std::set<std::string> &hostnames,
54 const std::string &username,
55 const std::string &password,
56 bool password_change_ok);
57
58 private:
60 const UserOptions &user_options, const std::string &username,
61 const std::set<std::string> &hostnames, const std::string &password,
62 bool password_change_ok, bool if_not_exists);
63
64 void create_accounts(const UserOptions &user_options,
65 const std::string &username,
66 const std::set<std::string> &hostnames,
67 const std::string &password, bool if_not_exists = false);
68
69 void create_users(const std::string &username,
70 const std::set<std::string> &hostnames,
71 const std::string &password, bool if_not_exists);
72
73 void give_grants_to_users(const UserOptions &user_options,
74 const std::string &new_accounts);
75 std::set<std::string> get_hostnames_of_created_accounts(
76 const std::string &username, const std::set<std::string> &hostnames,
77 bool if_not_exists);
78
80 enum {
81 kNotSet = 1, // =1 is not a requirement, just defensive programming
85 std::string accounts;
88};
89
90#endif // ROUTER_SRC_BOOTSTRAP_SRC_BOOTSTRAP_MYSQL_ACCOUNT_H_
std::vector< std::string > Strings
Definition: bootstrap_configurator.h:44
static constexpr unsigned kMaxPasswordRetries
Definition: bootstrap_mysql_account.h:35
Definition: bootstrap_mysql_account.h:48
std::string create_accounts_with_compliant_password(const UserOptions &user_options, const std::string &username, const std::set< std::string > &hostnames, const std::string &password, bool password_change_ok, bool if_not_exists)
Definition: bootstrap_mysql_account.cc:293
BootstrapMySQLAccount(mysqlrouter::MySQLSession *session)
Definition: bootstrap_mysql_account.h:50
void create_accounts(const UserOptions &user_options, const std::string &username, const std::set< std::string > &hostnames, const std::string &password, bool if_not_exists=false)
Definition: bootstrap_mysql_account.cc:348
void create_users(const std::string &username, const std::set< std::string > &hostnames, const std::string &password, bool if_not_exists)
Definition: bootstrap_mysql_account.cc:395
std::set< std::string > get_hostnames_of_created_accounts(const std::string &username, const std::set< std::string > &hostnames, bool if_not_exists)
Definition: bootstrap_mysql_account.cc:128
std::string create_router_accounts(const UserOptions &user_options, const std::set< std::string > &hostnames, const std::string &username, const std::string &password, bool password_change_ok)
create account to be used by Router.
Definition: bootstrap_mysql_account.cc:244
void give_grants_to_users(const UserOptions &user_options, const std::string &new_accounts)
Definition: bootstrap_mysql_account.cc:452
mysqlrouter::MySQLSession * mysql_
Definition: bootstrap_mysql_account.h:87
struct BootstrapMySQLAccount::UndoCreateAccountList undo_create_account_list_
Definition: mysql_session.h:157
static char * password
Definition: mysql_secure_installation.cc:58
Definition: bootstrap_mysql_account.h:79
@ kAllAccounts
Definition: bootstrap_mysql_account.h:82
@ kNotSet
Definition: bootstrap_mysql_account.h:81
@ kNewAccounts
Definition: bootstrap_mysql_account.h:83
enum BootstrapMySQLAccount::UndoCreateAccountList::@27 type
std::string accounts
Definition: bootstrap_mysql_account.h:85
Definition: bootstrap_mysql_account.h:38
std::string account_create
Definition: bootstrap_mysql_account.h:41
bool force_password_validation
Definition: bootstrap_mysql_account.h:42
uint64_t password_retries
Definition: bootstrap_mysql_account.h:40
bool autogenerated
Definition: bootstrap_mysql_account.h:45
Strings grant_role
Definition: bootstrap_mysql_account.h:44
std::string account
Definition: bootstrap_mysql_account.h:39