forked from kunpengcompute/mysql-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmysqlrouter.1
2477 lines (2477 loc) · 41.8 KB
/
mysqlrouter.1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
'\" t
.\" Title: \fBmysqlrouter\fR
.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author]
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 03/05/2020
.\" Manual: MySQL Router
.\" Source: MySQL 8.0
.\" Language: English
.\"
.TH "\FBMYSQLROUTER\FR" "1" "03/05/2020" "MySQL 8\&.0" "MySQL Router"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
mysqlrouter \- MySQL Router
.SH "SYNOPSIS"
.HP \w'\fBmysqlrouter\ [\fR\fB\fIoptions\fR\fR\fB]\fR\ 'u
\fBmysqlrouter [\fR\fB\fIoptions\fR\fR\fB]\fR
.SH "DESCRIPTION"
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
mysqlrouter Option Summaries
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
mysqlrouter Option Descriptions
.RE
.PP
MySQL Router accepts command line options that are passed into
\fBmysqlrouter\fR
to affect its behavior, or to bootstrap router based on an InnoDB cluster\&.
.PP
When starting Router, you can optionally use
\fB\-\-config\fR
to pass in the main configuration file\*(Aqs location (otherwise the default location is used) and
\fB\-\-extra\-config\fR
for an additional configuration file\&.
.PP
Bootstrapping command line options affect the generated files and directories that are used when starting MySQL Router\&.
mysqlrouter Option Summariesmysqlrouter Option Descriptions
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fB\-\-version\fR,
\fB\-V\fR
.TS
allbox tab(:);
lB lB.
T{
Property
T}:T{
Value
T}
.T&
l l.
T{
\fBCommand-Line Format\fR
T}:T{
--version , -V
T}
.TE
.sp 1
Displays the version number and related information of the application, and exits\&. For example:
.sp
.if n \{\
.RS 4
.\}
.nf
shell> \fBmysqlrouter \-\-version\fR
MySQL Router v8\&.0\&.21 on Linux (64\-bit) (GPL community edition)
.fi
.if n \{\
.RE
.\}
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fB\-\-help\fR,
\fB\-?\fR
.TS
allbox tab(:);
lB lB.
T{
Property
T}:T{
Value
T}
.T&
l l.
T{
\fBCommand-Line Format\fR
T}:T{
--help , -?
T}
.TE
.sp 1
Display help and informative information, and exit\&.
.sp
The
\fB\-\-help\fR
option has an added benefit\&. Along with the explanation of each of the options, the
\fB\-\-help\fR
option also displays the paths used to find the configuration file, and also several default paths\&. The following excerpt of the
\fB\-\-help\fR
output shows an example from a Ubuntu 16\&.04 machine:
.sp
.if n \{\
.RS 4
.\}
.nf
shell> \fBmysqlrouter \-\-help\fR
\&.\&.\&.
Start MySQL Router\&.
Configuration read from the following files in the given order (enclosed
in parentheses means not available for reading):
(/etc/mysqlrouter/mysqlrouter\&.conf)
/home/philip/\&.mysqlrouter\&.conf
Plugin Path:
/usr/lib/x86_64\-linux\-gnu/mysqlrouter
Default Log Directory:
/var/log/mysqlrouter
Default Persistent Data Directory:
/var/lib/mysqlrouter
Default Runtime State Directory:
/run/mysqlrouter
Usage: mysqlrouter [\-V|\-\-version] [\-?|\-\-help]
\&.\&.\&.
.fi
.if n \{\
.RE
.\}
.sp
The configuration section shows the order for the paths that may be used for reading the configuration file\&. In this case, only the second file is accessible\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fB\-\-bootstrap \fR\fB\fIURI\fR\fR,
\fB\-B \fR\fB\fIURI\fR\fR
.TS
allbox tab(:);
lB lB.
T{
Property
T}:T{
Value
T}
.T&
l l
l l.
T{
\fBCommand-Line Format\fR
T}:T{
--bootstrap URI, -B URI
T}
T{
\fBType\fR
T}:T{
String
T}
.TE
.sp 1
The main option to perform a bootstrap of MySQL Router by connecting to the InnoDB cluster metadata server at the URI provided\&. MySQL Router configures itself based on the information retrieved from the InnoDB cluster metadata server\&. A password is prompted for if needed\&. If a username is not provided as part of the URI then the default user name "root" is used\&. See
\m[blue]\fBConnecting Using URI\-Like Connection Strings\fR\m[]\&\s-2\u[1]\d\s+2
for information on using a path to specify a server instance\&.
.if n \{\
.sp
.\}
.RS 4
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBNote\fR
.ps -1
.br
While
\fB\-\-bootstrap\fR
accepts a URI for TCP/IP connections, using the
\fB\-\-bootstrap\-socket\fR
option with a local Unix domain socket name replaces the "host:port" part of the URI passed to the
\fB\-\-bootstrap\fR
option with the socket on the same machine\&.
.sp .5v
.RE
By default, the bootstrap process performs a system\-wide configuration of MySQL Router\&. Only one instance of MySQL Router can be configured for system\-wide operation\&. The system instance of MySQL Router has a
router_name
of "system"\&. If additional instances are desired, use the
\fB\-\-directory\fR
option to create self\-contained MySQL Router installations\&.
.sp
\fIURI\fR: a server instance from an InnoDB cluster to fetch metadata information from\&. If the provided
\fIURI\fR
is a read\-only instance, MySQL Router automatically reconnects to a read\-write instance in the InnoDB cluster so it can register MySQL Router\&.
.sp
If a configuration file already exists when you start MySQL Router with the
\fB\-\-bootstrap\fR, the existing
router_id
in that file is reused, and a reconfiguration process occurs\&. The configuration file is regenerated from scratch and the MySQL Router\*(Aqs metadata server account is recreated, although with the same name\&.
.sp
During the reconfiguration process, all changes made to an existing configuration file are discarded\&. To customize a configuration file and still retain the ability of automatic reconfiguration (bootstrapping), you can use the
\fB\-\-extra\-config\fR
command line option to specify an additional configuration file that is read after the main configuration file\&. These configuration options are used because this extra configuration file is loaded after the main configuration file\&.
.sp
The bootstrap process creates a new MySQL user account with a randomly generated password to use by that specific MySQL Router instance\&. This account is used by MySQL Router when connecting to the metadata server and InnoDB cluster to fetch information about its current state\&. For detailed information about this user including how its password is stored and the MySQL privilege it requires, see documentation for the
\fBMySQL user option\fR\&.
.sp
The generated configuration file is named
mysqlrouter\&.conf, and its location depends on the type of instance being configured, the system, and the package\&. For system\-wide installations, the generated configuration file is added to the system\*(Aqs configuration directory such as
/etc
or
%PROGRAMDATA%\eMySQL\eMySQL Router\e\&. Executing
mysqlrouter \-\-help
will display this location\&.
.sp
The
\fB\-\-user\fR
option is required if executing a bootstrap with a super user (uid=0)\&. Although not recommended, forcing the super user is possible by passing its name as an argument such as
\fI\-\-user=root\fR\&.
.if n \{\
.sp
.\}
.RS 4
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBNote\fR
.ps -1
.br
The minimum GRANT permissions required to execute
\fB\-\-boostrap\fR
are:
.sp
.if n \{\
.RS 4
.\}
.nf
GRANT CREATE USER ON *\&.* TO \*(Aq\fIbootstrapuser\fR\*(Aq@\*(Aq%\*(Aq WITH GRANT OPTION;
GRANT SELECT, INSERT, UPDATE, DELETE ON mysql_innodb_cluster_metadata\&.* TO
\*(Aq\fIbootstrapuser\fR\*(Aq@\*(Aq%\*(Aq;
GRANT SELECT ON mysql\&.user TO \*(Aq\fIbootstrapuser\fR\*(Aq@\*(Aq%\*(Aq;
GRANT SELECT ON performance_schema\&.replication_group_members TO
\*(Aq\fIbootstrapuser\fR\*(Aq@\*(Aq%\*(Aq;
GRANT SELECT ON performance_schema\&.replication_group_member_stats TO
\*(Aq\fIbootstrapuser\fR\*(Aq@\*(Aq%\*(Aq;
.fi
.if n \{\
.RE
.\}
.sp .5v
.RE
Using
\fB\-\-bootstrap\fR
adds default values to the generated MySQL Router configuration file, and some of these default values depend on other conditions\&. Listed below are some of the conditions that affect the generated default values, where default is defined by passing in
\fB\-\-bootstrap\fR
by itself\&.
.sp
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.B Table\ \&4.2.\ \&Conditions that affect default \-\-bootstrap values
.TS
allbox tab(:);
lB lB.
T{
Condition
T}:T{
Description
T}
.T&
l l
l l
l l
l l
l l.
T{
\fB--conf-base-port\fR
T}:T{
.PP
Modifies generated
\fBbind_port\fR
values for each connection type.
.PP
By default, generated
\fBbind_port\fR
values are as follows: For the classic protocol, Read-Write uses 6446 and Read-Only uses 6447, and for the X protocol Read-Write uses 64460 and Read-Only uses 64470.
T}
T{
\fB--conf-use-sockets\fR
T}:T{
Inserts \fBsocket\fR definitions for each connection type.
T}
T{
\fB--conf-skip-tcp\fR
T}:T{
TCP/IP connection definitions are not defined.
T}
T{
\fB--directory\fR
T}:T{
Affects all file paths, and also generates additional files.
T}
T{
Other
T}:T{
This list is not exhaustive, other options and conditions also affect
the generated values.
T}
.TE
.sp 1
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fB\-\-bootstrap\-socket \fR\fB\fIsocket_name\fR\fR
.TS
allbox tab(:);
lB lB.
T{
Property
T}:T{
Value
T}
.T&
l l
l l.
T{
\fBCommand-Line Format\fR
T}:T{
--bootstrap-socket socket_name
T}
T{
\fBPlatform Specific\fR
T}:T{
Linux
T}
.TE
.sp 1
Used in conjunction with
\fB\-\-bootstrap\fR
to bootstrap using a local Unix domain socket instead of TCP/IP\&. The
\fB\-\-bootstrap\-socket\fR
value replaces the "host:port" part in the
\fB\-\-bootstrap\fR
definition with the assigned socket name for connecting to the MySQL metadata server using Unix domain sockets\&. This is the MySQL instance that is being bootstrapped from, and this instance must be on the same machine if sockets are used\&. For additional details about how bootstrapping works, see
\fB\-\-bootstrap\fR\&.
.sp
This option is different than the
\fB\-\-conf\-use\-sockets\fR
command line option that sets the
\fBsocket\fR
configuration file option during the bootstrap process\&.
.sp
This option is not available on Windows\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fB\-\-directory \fR\fB\fIdir_path\fR\fR,
\fB\-d \fR\fB\fIdir_path\fR\fR
.TS
allbox tab(:);
lB lB.
T{
Property
T}:T{
Value
T}
.T&
l l
l l.
T{
\fBCommand-Line Format\fR
T}:T{
--directory dir_path, -d dir_path
T}
T{
\fBType\fR
T}:T{
String
T}
.TE
.sp 1
Specifies that a self\-contained MySQL Router installation will be created at the defined directory instead of configuring the system\-wide router instance\&. This also allows multiple router instances to be created on the same system\&.
.sp
The self\-contained directory structure for Router is:
.sp
.if n \{\
.RS 4
.\}
.nf
$path/start\&.sh
$path/stop\&.sh
$path/mysqlrouter\&.pid
$path/mysqlrouter\&.conf
$path/mysqlrouter\&.key
$path/run
$path/run/keyring
$path/data
$path/log
$path/log/mysqlrouter\&.log
.fi
.if n \{\
.RE
.\}
.sp
If this option is specified, the keyring file is stored under the runtime state directory of that instance, under
run/
in the specified directory, as opposed to the system\-wide runtime state directory\&.
.sp
If
\fB\-\-conf\-use\-sockets\fR
is also enabled then the generated socket files are also added to this directory\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fB\-\-master\-key\-writer\fR
.TS
allbox tab(:);
lB lB.
T{
Property
T}:T{
Value
T}
.T&
l l
l l
l l.
T{
\fBCommand-Line Format\fR
T}:T{
--master-key-writer file_path
T}
T{
\fBIntroduced\fR
T}:T{
8.0.12
T}
T{
\fBType\fR
T}:T{
String
T}
.TE
.sp 1
This optional bootstrap option accepts a script that reads the master key from
\fISTDIN\fR\&. It also uses the
\fIROUTER_ID\fR
environment variable set by MySQL Router before the
\fBmaster\-key\-writer\fR
script is called\&.
.sp
The
\fBmaster\-key\-writer\fR
and
\fBmaster\-key\-reader\fR
options must be used together, and using them means the
\fBmaster_key_file\fR
option must not be defined in
mysqlrouter\&.conf
as the master key is not written to the
mysqlrouter\&.key
master key file\&.
.sp
This is also written to the generated MySQL Router configuration file as the
\fBmaster\-key\-writer\fR
[DEFAULT] option\&.
.sp
Example contents of a bash script named
writer\&.sh
used in our example:
.sp
.if n \{\
.RS 4
.\}
.nf
#!/bin/bash
KID_=$(keyctl padd user ${ROUTER_ID} @us <&0)
.fi
.if n \{\
.RE
.\}
.sp
Example usage:
.sp
.if n \{\
.RS 4
.\}
.nf
shell> mysqlrouter \-\-bootstrap=127\&.0\&.0\&.1:3310 \-\-master\-key\-reader=\&./reader\&.sh \-\-master\-key\-writer=\&./writer\&.sh
.fi
.if n \{\
.RE
.\}
.sp
This also affects the generated
mysqlrouter\&.conf, for example:
.sp
.if n \{\
.RS 4
.\}
.nf
[DEFAULT]
\&.\&.\&.
master\-key\-reader=reader\&.sh
master\-key\-writer=writer\&.sh
.fi
.if n \{\
.RE
.\}
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fB\-\-master\-key\-reader\fR
.TS
allbox tab(:);
lB lB.
T{
Property
T}:T{
Value
T}
.T&
l l
l l
l l.
T{
\fBCommand-Line Format\fR
T}:T{
--master-key-reader file_path
T}
T{
\fBIntroduced\fR
T}:T{
8.0.12
T}
T{
\fBType\fR
T}:T{
String
T}
.TE
.sp 1
This optional bootstrap option accepts a script that writes the master key to
\fISTDOUT\fR\&. It also uses the
\fIROUTER_ID\fR
environment variable set by MySQL Router before the
\fBmaster\-key\-reader\fR
script is called\&.
.sp
The
\fBmaster\-key\-reader\fR
and
\fBmaster\-key\-writer\fR
options must be used together, and using them means the
\fBmaster_key_file\fR
option must not be defined in
mysqlrouter\&.conf
as the master key is not written to the
mysqlrouter\&.key
master key file, and instead uses the value provided by this option\*(Aqs script\&.
.sp
This is also written to the generated MySQL Router configuration file as the
\fBmaster\-key\-reader\fR
[DEFAULT] option\&.
.sp
Example contents of a bash script named
reader\&.sh
used in our example:
.sp
.if n \{\
.RS 4
.\}
.nf
#!/bin/bash
KID_=$(keyctl search @us user ${ROUTER_ID} 2>/dev/null)
if [ ! \-z $KID_ ]; then
keyctl pipe $KID_
fi
.fi
.if n \{\
.RE
.\}
.sp
Example usage:
.sp
.if n \{\
.RS 4
.\}
.nf
shell> mysqlrouter \-\-bootstrap=127\&.0\&.0\&.1:3310 \-\-master\-key\-reader=\&./reader\&.sh \-\-master\-key\-writer=\&./writer\&.sh
.fi
.if n \{\
.RE
.\}
.sp
This also affects the generated
mysqlrouter\&.conf, for example:
.sp
.if n \{\
.RS 4
.\}
.nf
[DEFAULT]
\&.\&.\&.
master\-key\-reader=reader\&.sh
master\-key\-writer=writer\&.sh
.fi
.if n \{\
.RE
.\}
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fB\-\-strict\fR
.TS
allbox tab(:);
lB lB.
T{
Property
T}:T{
Value
T}
.T&
l l
l l
l l.
T{
\fBCommand-Line Format\fR
T}:T{
--strict
T}
T{
\fBIntroduced\fR
T}:T{
8.0.19
T}
T{
\fBType\fR
T}:T{
String
T}
.TE
.sp 1
Enables strict mode, which for example causes the bootstrap
\fB\-\-account\fR
user verification check to stop the bootstrap process rather than only emit a warning and continue if the supplied user does not pass the check\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fB\-\-account\fR
.TS
allbox tab(:);
lB lB.
T{
Property
T}:T{
Value
T}
.T&
l l
l l
l l.
T{
\fBCommand-Line Format\fR
T}:T{
--account username
T}
T{
\fBIntroduced\fR
T}:T{
8.0.19
T}
T{
\fBType\fR
T}:T{
String
T}
.TE
.sp 1
A bootstrap option to specify the MySQL user to use, which either reuses an existing MySQL user account or creates one; behavior controlled by the related
\fB\-\-account\-create\fR
option\&.
.sp
With
\fB\-\-account\fR, usage favors ease of management over ease of deployment as multiple routers may share the same account, and the username and password are manually defined rather than auto\-generated\&.
.sp
Setting this option triggers a password prompt for this account regardless of whether the password is available in the keyring\&.
.sp
Bootstrapping without passing in
\fB\-\-account\fR
does not recreate an existing MySQL server account\&. Prior to MySQL Router 8\&.0\&.18, bootstrapping would DROP the existing user and reCREATE it\&.
.sp
Using this option assumes the user has sufficient access rights for Router because the bootstrap process does not attempt to add missing grants to existing accounts\&. The bootstrap process does verify the permissions and outputs information to the console of the failed check\&. The bootstrap process continues despite these failed checks unless the optional
\fB\-\-strict\fR
option is also used\&. Example required permissions:
.sp
.if n \{\
.RS 4
.\}
.nf
GRANT SELECT ON mysql_innodb_cluster_metadata\&.* TO `theuser`
GRANT SELECT ON performance_schema\&.replication_group_members TO `theuser`
GRANT SELECT ON performance_schema\&.replication_group_member_stats TO `theuser`
.fi
.if n \{\
.RE
.\}
.sp
A password is not accepted from the command\-line\&. For example, passing in "foo:bar" assumes "foo:bar" is the desired username rather than user
\fIfoo\fR
with the password
\fIbar\fR\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fB\-\-account\-create\fR
.TS
allbox tab(:);
lB lB.
T{
Property
T}:T{
Value
T}
.T&
l l
l l
l l
l l
l l.
T{
\fBCommand-Line Format\fR
T}:T{
--account-create behavior
T}
T{
\fBIntroduced\fR
T}:T{
8.0.19
T}
T{
\fBType\fR
T}:T{
String
T}
T{
\fBDefault Value\fR
T}:T{
if-not-exists
T}
T{
\fBValid Values\fR
T}:T{
.PP
if-not-exists
.PP
always
.PP
never
T}
.TE
.sp 1
Specify the account creation policy to help guard against accidentally bootstrapping with the wrong user account\&. Potential values are:
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
if\-not\-exists
(default): Bootstrap either way; reuse the account if it exists, otherwise create it\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
always: Only bootstrap if the account does not already exist; and create it\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
never: Only bootstrap if the account already exists; and reuse it\&.
.RE
.sp
This option requires that the
\fB\-\-account\fR
option is also used, and that
\fB\-\-account\-host\fR
is not used\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fB\-\-account\-host\fR
.TS
allbox tab(:);
lB lB.
T{
Property
T}:T{
Value
T}
.T&
l l
l l
l l
l l.
T{
\fBCommand-Line Format\fR
T}:T{
--account-host host_pattern
T}
T{
\fBIntroduced\fR
T}:T{
8.0.12
T}
T{
\fBType\fR
T}:T{
String
T}
T{
\fBDefault Value\fR
T}:T{
%
T}
.TE
.sp 1
The host pattern used for accounts created by MySQL Router during the bootstrap process\&. This is optional and defaults to \*(Aq%\*(Aq\&.
.sp
Pass in this option multiple times to define multiple patterns, in which case the generated MySQL accounts use the same password\&.
.if n \{\
.sp
.\}
.RS 4
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBNote\fR
.ps -1
.br
Router does not perform sanity checking and does not ensure that the pattern authorizes Router to connect\&.
.sp .5v
.RE
.if n \{\
.sp
.\}
.RS 4
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBNote\fR
.ps -1
.br
Bootstrapping reuses existing Router accounts by dropping and recreating the user, and this user recreation process applies to every host\&.
.sp .5v
.RE
Examples:
.sp
.if n \{\
.RS 4
.\}
.nf
# One host
shell> mysqlrouter \-\-bootstrap localhost:3310 \-\-account\-host host1
# Or, multiple hosts
shell> mysqlrouter \-\-bootstrap localhost:3310 \-\-account\-host host1 \-\-account\-host host2 \-\-account\-host host3
.fi
.if n \{\
.RE
.\}
.RE
.sp