You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

785 lines
22 KiB

  1. #!/usr/bin/perl
  2. use Getopt::Long;
  3. use POSIX qw(strftime getcwd);
  4. $|=1;
  5. $VER="2.16";
  6. my @defaults_options; # Leading --no-defaults, --defaults-file, etc.
  7. $opt_example = 0;
  8. $opt_help = 0;
  9. $opt_log = undef();
  10. $opt_mysqladmin = "@bindir@/mysqladmin";
  11. $opt_mysqld = "@libexecdir@/mysqld";
  12. $opt_no_log = 0;
  13. $opt_password = undef();
  14. $opt_tcp_ip = 0;
  15. $opt_user = "root";
  16. $opt_version = 0;
  17. $opt_silent = 0;
  18. $opt_verbose = 0;
  19. my $my_print_defaults_exists= 1;
  20. my $logdir= undef();
  21. my ($mysqld, $mysqladmin, $groupids, $homedir, $my_progname);
  22. $homedir = $ENV{HOME};
  23. $my_progname = $0;
  24. $my_progname =~ s/.*[\/]//;
  25. main();
  26. ####
  27. #### main sub routine
  28. ####
  29. sub main
  30. {
  31. my $flag_exit= 0;
  32. if (!defined(my_which(my_print_defaults)))
  33. {
  34. # We can't throw out yet, since --version, --help, or --example may
  35. # have been given
  36. print "WARNING: my_print_defaults command not found.\n";
  37. print "Please make sure you have this command available and\n";
  38. print "in your path. The command is available from the latest\n";
  39. print "MySQL distribution.\n";
  40. $my_print_defaults_exists= 0;
  41. }
  42. # Remove leading defaults options from @ARGV
  43. while (@ARGV > 0)
  44. {
  45. last unless $ARGV[0] =~
  46. /^--(?:no-defaults$|(?:defaults-file|defaults-extra-file)=)/;
  47. push @defaults_options, (shift @ARGV);
  48. }
  49. foreach (@defaults_options)
  50. {
  51. $_ = quote_shell_word($_);
  52. }
  53. # Add [mysqld_multi] options to front of @ARGV, ready for GetOptions()
  54. unshift @ARGV, defaults_for_group('mysqld_multi');
  55. # We've already handled --no-defaults, --defaults-file, etc.
  56. if (!GetOptions("help", "example", "version", "mysqld=s", "mysqladmin=s",
  57. "user=s", "password=s", "log=s", "no-log",
  58. "tcp-ip", "silent", "verbose"))
  59. {
  60. $flag_exit= 1;
  61. }
  62. usage() if ($opt_help);
  63. if ($opt_verbose && $opt_silent)
  64. {
  65. print "Both --verbose and --silent have been given. Some of the warnings ";
  66. print "will be disabled\nand some will be enabled.\n\n";
  67. }
  68. init_log() if (!defined($opt_log));
  69. $groupids = $ARGV[1];
  70. if ($opt_version)
  71. {
  72. print "$my_progname version $VER by Jani Tolonen\n";
  73. exit(0);
  74. }
  75. example() if ($opt_example);
  76. if ($flag_exit)
  77. {
  78. print "Error with an option, see $my_progname --help for more info.\n";
  79. exit(1);
  80. }
  81. if (!defined(my_which(my_print_defaults)))
  82. {
  83. print "ABORT: Can't find command 'my_print_defaults'.\n";
  84. print "This command is available from the latest MySQL\n";
  85. print "distribution. Please make sure you have the command\n";
  86. print "in your PATH.\n";
  87. exit(1);
  88. }
  89. usage() if (!defined($ARGV[0]) ||
  90. (!($ARGV[0] =~ m/^start$/i) &&
  91. !($ARGV[0] =~ m/^stop$/i) &&
  92. !($ARGV[0] =~ m/^report$/i)));
  93. if (!$opt_no_log)
  94. {
  95. w2log("$my_progname log file version $VER; run: ",
  96. "$opt_log", 1, 0);
  97. }
  98. else
  99. {
  100. print "$my_progname log file version $VER; run: ";
  101. print strftime "%a %b %e %H:%M:%S %Y", localtime;
  102. print "\n";
  103. }
  104. if ($ARGV[0] =~ m/^start$/i)
  105. {
  106. if (!defined(($mysqld= my_which($opt_mysqld))) && $opt_verbose)
  107. {
  108. print "WARNING: Couldn't find the default mysqld binary.\n";
  109. print "Tried: $opt_mysqld\n";
  110. print "This is OK, if you are using option \"mysqld=...\" in ";
  111. print "groups [mysqldN] separately for each.\n\n";
  112. }
  113. start_mysqlds();
  114. }
  115. else
  116. {
  117. if (!defined(($mysqladmin= my_which($opt_mysqladmin))) && $opt_verbose)
  118. {
  119. print "WARNING: Couldn't find the default mysqladmin binary.\n";
  120. print "Tried: $opt_mysqladmin\n";
  121. print "This is OK, if you are using option \"mysqladmin=...\" in ";
  122. print "groups [mysqldN] separately for each.\n\n";
  123. }
  124. if ($ARGV[0] =~ m/^report$/i)
  125. {
  126. report_mysqlds();
  127. }
  128. else
  129. {
  130. stop_mysqlds();
  131. }
  132. }
  133. }
  134. #
  135. # Quote word for shell
  136. #
  137. sub quote_shell_word
  138. {
  139. my ($option)= @_;
  140. $option =~ s!([^\w=./-])!\\$1!g;
  141. return $option;
  142. }
  143. sub defaults_for_group
  144. {
  145. my ($group) = @_;
  146. return () unless $my_print_defaults_exists;
  147. my $com= join ' ', 'my_print_defaults', @defaults_options, $group;
  148. my @defaults = `$com`;
  149. chomp @defaults;
  150. return @defaults;
  151. }
  152. ####
  153. #### Init log file. Check for appropriate place for log file, in the following
  154. #### order: my_print_defaults mysqld datadir, @datadir@
  155. ####
  156. sub init_log
  157. {
  158. foreach my $opt (defaults_for_group('mysqld'))
  159. {
  160. if ($opt =~ m/^--datadir=(.*)/ && -d "$1" && -w "$1")
  161. {
  162. $logdir= $1;
  163. }
  164. }
  165. if (!defined($logdir))
  166. {
  167. $logdir= "@datadir@" if (-d "@datadir@" && -w "@datadir@");
  168. }
  169. if (!defined($logdir))
  170. {
  171. # Log file was not specified and we could not log to a standard place,
  172. # so log file be disabled for now.
  173. if (!$opt_silent)
  174. {
  175. print "WARNING: Log file disabled. Maybe directory or file isn't writable?\n";
  176. }
  177. $opt_no_log= 1;
  178. }
  179. else
  180. {
  181. $opt_log= "$logdir/mysqld_multi.log";
  182. }
  183. }
  184. ####
  185. #### Report living and not running MySQL servers
  186. ####
  187. sub report_mysqlds
  188. {
  189. my (@groups, $com, $i, @options, $pec);
  190. print "Reporting MySQL servers\n";
  191. if (!$opt_no_log)
  192. {
  193. w2log("\nReporting MySQL servers","$opt_log",0,0);
  194. }
  195. @groups = &find_groups($groupids);
  196. for ($i = 0; defined($groups[$i]); $i++)
  197. {
  198. $com= get_mysqladmin_options($i, @groups);
  199. $com.= " ping >> /dev/null 2>&1";
  200. system($com);
  201. $pec = $? >> 8;
  202. if ($pec)
  203. {
  204. print "MySQL server from group: $groups[$i] is not running\n";
  205. if (!$opt_no_log)
  206. {
  207. w2log("MySQL server from group: $groups[$i] is not running",
  208. "$opt_log", 0, 0);
  209. }
  210. }
  211. else
  212. {
  213. print "MySQL server from group: $groups[$i] is running\n";
  214. if (!$opt_no_log)
  215. {
  216. w2log("MySQL server from group: $groups[$i] is running",
  217. "$opt_log", 0, 0);
  218. }
  219. }
  220. }
  221. if (!$i)
  222. {
  223. print "No groups to be reported (check your GNRs)\n";
  224. if (!$opt_no_log)
  225. {
  226. w2log("No groups to be reported (check your GNRs)", "$opt_log", 0, 0);
  227. }
  228. }
  229. }
  230. ####
  231. #### start multiple servers
  232. ####
  233. sub start_mysqlds()
  234. {
  235. my (@groups, $com, $tmp, $i, @options, $j, $mysqld_found, $info_sent);
  236. if (!$opt_no_log)
  237. {
  238. w2log("\nStarting MySQL servers\n","$opt_log",0,0);
  239. }
  240. else
  241. {
  242. print "\nStarting MySQL servers\n";
  243. }
  244. @groups = &find_groups($groupids);
  245. for ($i = 0; defined($groups[$i]); $i++)
  246. {
  247. @options = defaults_for_group($groups[$i]);
  248. $basedir_found= 0; # The default
  249. $mysqld_found= 1; # The default
  250. $mysqld_found= 0 if (!length($mysqld));
  251. $com= "$mysqld";
  252. for ($j = 0, $tmp= ""; defined($options[$j]); $j++)
  253. {
  254. if ("--mysqladmin=" eq substr($options[$j], 0, 13))
  255. {
  256. # catch this and ignore
  257. }
  258. elsif ("--mysqld=" eq substr($options[$j], 0, 9))
  259. {
  260. $options[$j]=~ s/\-\-mysqld\=//;
  261. $com= $options[$j];
  262. $mysqld_found= 1;
  263. }
  264. elsif ("--basedir=" eq substr($options[$j], 0, 10))
  265. {
  266. $basedir= $options[$j];
  267. $basedir =~ s/^--basedir=//;
  268. $basedir_found= 1;
  269. $options[$j]= quote_shell_word($options[$j]);
  270. $tmp.= " $options[$j]";
  271. }
  272. else
  273. {
  274. $options[$j]= quote_shell_word($options[$j]);
  275. $tmp.= " $options[$j]";
  276. }
  277. }
  278. if ($opt_verbose && $com =~ m/\/(safe_mysqld|mysqld_safe)$/ && !$info_sent)
  279. {
  280. print "WARNING: $1 is being used to start mysqld. In this case you ";
  281. print "may need to pass\n\"ledir=...\" under groups [mysqldN] to ";
  282. print "$1 in order to find the actual mysqld binary.\n";
  283. print "ledir (library executable directory) should be the path to the ";
  284. print "wanted mysqld binary.\n\n";
  285. $info_sent= 1;
  286. }
  287. $com.= $tmp;
  288. $com.= " >> $opt_log 2>&1" if (!$opt_no_log);
  289. $com.= " &";
  290. if (!$mysqld_found)
  291. {
  292. print "\n";
  293. print "FATAL ERROR: Tried to start mysqld under group [$groups[$i]], ";
  294. print "but no mysqld binary was found.\n";
  295. print "Please add \"mysqld=...\" in group [mysqld_multi], or add it to ";
  296. print "group [$groups[$i]] separately.\n";
  297. exit(1);
  298. }
  299. if ($basedir_found)
  300. {
  301. $curdir=getcwd();
  302. chdir($basedir) or die "Can't change to datadir $basedir";
  303. }
  304. system($com);
  305. if ($basedir_found)
  306. {
  307. chdir($curdir) or die "Can't change back to original dir $curdir";
  308. }
  309. }
  310. if (!$i && !$opt_no_log)
  311. {
  312. w2log("No MySQL servers to be started (check your GNRs)",
  313. "$opt_log", 0, 0);
  314. }
  315. }
  316. ####
  317. #### stop multiple servers
  318. ####
  319. sub stop_mysqlds()
  320. {
  321. my (@groups, $com, $i, @options);
  322. if (!$opt_no_log)
  323. {
  324. w2log("\nStopping MySQL servers\n","$opt_log",0,0);
  325. }
  326. else
  327. {
  328. print "\nStopping MySQL servers\n";
  329. }
  330. @groups = &find_groups($groupids);
  331. for ($i = 0; defined($groups[$i]); $i++)
  332. {
  333. $com= get_mysqladmin_options($i, @groups);
  334. $com.= " shutdown";
  335. $com.= " >> $opt_log 2>&1" if (!$opt_no_log);
  336. $com.= " &";
  337. system($com);
  338. }
  339. if (!$i && !$opt_no_log)
  340. {
  341. w2log("No MySQL servers to be stopped (check your GNRs)",
  342. "$opt_log", 0, 0);
  343. }
  344. }
  345. ####
  346. #### Sub function for mysqladmin option parsing
  347. ####
  348. sub get_mysqladmin_options
  349. {
  350. my ($i, @groups)= @_;
  351. my ($mysqladmin_found, $com, $tmp, $j);
  352. @options = defaults_for_group($groups[$i]);
  353. $mysqladmin_found= 1; # The default
  354. $mysqladmin_found= 0 if (!length($mysqladmin));
  355. $com = "$mysqladmin";
  356. $tmp = " -u $opt_user";
  357. if (defined($opt_password)) {
  358. my $pw= $opt_password;
  359. # Protect single quotes in password
  360. $pw =~ s/'/'"'"'/g;
  361. $tmp.= " -p'$pw'";
  362. }
  363. $tmp.= $opt_tcp_ip ? " -h 127.0.0.1" : "";
  364. for ($j = 0; defined($options[$j]); $j++)
  365. {
  366. if ("--mysqladmin=" eq substr($options[$j], 0, 13))
  367. {
  368. $options[$j]=~ s/\-\-mysqladmin\=//;
  369. $com= $options[$j];
  370. $mysqladmin_found= 1;
  371. }
  372. elsif ((($options[$j] =~ m/^(\-\-socket\=)(.*)$/) && !$opt_tcp_ip) ||
  373. ($options[$j] =~ m/^(\-\-port\=)(.*)$/))
  374. {
  375. $tmp.= " $options[$j]";
  376. }
  377. }
  378. if (!$mysqladmin_found)
  379. {
  380. print "\n";
  381. print "FATAL ERROR: Tried to use mysqladmin in group [$groups[$i]], ";
  382. print "but no mysqladmin binary was found.\n";
  383. print "Please add \"mysqladmin=...\" in group [mysqld_multi], or ";
  384. print "in group [$groups[$i]].\n";
  385. exit(1);
  386. }
  387. $com.= $tmp;
  388. return $com;
  389. }
  390. # Return a list of option files which can be opened. Similar, but not
  391. # identical, to behavior of my_search_option_files()
  392. sub list_defaults_files
  393. {
  394. my %opt;
  395. foreach (@defaults_options)
  396. {
  397. return () if /^--no-defaults$/;
  398. $opt{$1} = $2 if /^--defaults-(extra-file|file)=(.*)$/;
  399. }
  400. return ($opt{file}) if exists $opt{file};
  401. my %seen; # Don't list the same file more than once
  402. return grep { defined $_ and not $seen{$_}++ and -f $_ and -r $_ }
  403. ('/etc/my.cnf',
  404. '/etc/mysql/my.cnf',
  405. '@sysconfdir@/my.cnf',
  406. ($ENV{MYSQL_HOME} ? "$ENV{MYSQL_HOME}/my.cnf" : undef),
  407. $opt{'extra-file'},
  408. ($ENV{HOME} ? "$ENV{HOME}/.my.cnf" : undef));
  409. }
  410. # Takes a specification of GNRs (see --help), and returns a list of matching
  411. # groups which actually are mentioned in a relevant config file
  412. sub find_groups
  413. {
  414. my ($raw_gids) = @_;
  415. my %gids;
  416. my @groups;
  417. if (defined($raw_gids))
  418. {
  419. # Make a hash of the wanted group ids
  420. foreach my $raw_gid (split ',', $raw_gids)
  421. {
  422. # Match 123 or 123-456
  423. my ($start, $end) = ($raw_gid =~ /^\s*(\d+)(?:\s*-\s*(\d+))?\s*$/);
  424. $end = $start if not defined $end;
  425. if (not defined $start or $end < $start or $start < 0)
  426. {
  427. print "ABORT: Bad GNR: $raw_gid; see $my_progname --help\n";
  428. exit(1);
  429. }
  430. foreach my $i ($start .. $end)
  431. {
  432. # Use $i + 0 to normalize numbers (002 + 0 -> 2)
  433. $gids{$i + 0}= 1;
  434. }
  435. }
  436. }
  437. my @defaults_files = list_defaults_files();
  438. #warn "@{[sort keys %gids]} -> @defaults_files\n";
  439. foreach my $file (@defaults_files)
  440. {
  441. next unless open CONF, "< $file";
  442. while (<CONF>)
  443. {
  444. if (/^\s*\[\s*(mysqld)(\d+)\s*\]\s*$/)
  445. {
  446. #warn "Found a group: $1$2\n";
  447. # Use $2 + 0 to normalize numbers (002 + 0 -> 2)
  448. if (not defined($raw_gids) or $gids{$2 + 0})
  449. {
  450. push @groups, "$1$2";
  451. }
  452. }
  453. }
  454. close CONF;
  455. }
  456. return @groups;
  457. }
  458. ####
  459. #### w2log: Write to a logfile.
  460. #### 1.arg: append to the log file (given string, or from a file. if a file,
  461. #### file will be read from $opt_logdir)
  462. #### 2.arg: logfile -name (w2log assumes that the logfile is in $opt_logdir).
  463. #### 3.arg. 0 | 1, if true, print current date to the logfile. 3. arg will
  464. #### be ignored, if 1. arg is a file.
  465. #### 4.arg. 0 | 1, if true, first argument is a file, else a string
  466. ####
  467. sub w2log
  468. {
  469. my ($msg, $file, $date_flag, $is_file)= @_;
  470. my (@data);
  471. open (LOGFILE, ">>$opt_log")
  472. or die "FATAL: w2log: Couldn't open log file: $opt_log\n";
  473. if ($is_file)
  474. {
  475. open (FROMFILE, "<$msg") && (@data=<FROMFILE>) &&
  476. close(FROMFILE)
  477. or die "FATAL: w2log: Couldn't open file: $msg\n";
  478. foreach my $line (@data)
  479. {
  480. print LOGFILE "$line";
  481. }
  482. }
  483. else
  484. {
  485. print LOGFILE "$msg";
  486. print LOGFILE strftime "%a %b %e %H:%M:%S %Y", localtime if ($date_flag);
  487. print LOGFILE "\n";
  488. }
  489. close (LOGFILE);
  490. return;
  491. }
  492. ####
  493. #### my_which is used, because we can't assume that every system has the
  494. #### which -command. my_which can take only one argument at a time.
  495. #### Return values: requested system command with the first found path,
  496. #### or undefined, if not found.
  497. ####
  498. sub my_which
  499. {
  500. my ($command) = @_;
  501. my (@paths, $path);
  502. return $command if (-f $command && -x $command);
  503. @paths = split(':', $ENV{'PATH'});
  504. foreach $path (@paths)
  505. {
  506. $path .= "/$command";
  507. return $path if (-f $path && -x $path);
  508. }
  509. return undef();
  510. }
  511. ####
  512. #### example
  513. ####
  514. sub example
  515. {
  516. print <<EOF;
  517. # This is an example of a my.cnf file for $my_progname.
  518. # Usually this file is located in home dir ~/.my.cnf or /etc/my.cnf
  519. #
  520. # SOME IMPORTANT NOTES FOLLOW:
  521. #
  522. # 1.COMMON USER
  523. #
  524. # Make sure that the MySQL user, who is stopping the mysqld services, has
  525. # the same password to all MySQL servers being accessed by $my_progname.
  526. # This user needs to have the 'Shutdown_priv' -privilege, but for security
  527. # reasons should have no other privileges. It is advised that you create a
  528. # common 'multi_admin' user for all MySQL servers being controlled by
  529. # $my_progname. Here is an example how to do it:
  530. #
  531. # GRANT SHUTDOWN ON *.* TO multi_admin\@localhost IDENTIFIED BY 'password'
  532. #
  533. # You will need to apply the above to all MySQL servers that are being
  534. # controlled by $my_progname. 'multi_admin' will shutdown the servers
  535. # using 'mysqladmin' -binary, when '$my_progname stop' is being called.
  536. #
  537. # 2.PID-FILE
  538. #
  539. # If you are using mysqld_safe to start mysqld, make sure that every
  540. # MySQL server has a separate pid-file. In order to use mysqld_safe
  541. # via $my_progname, you need to use two options:
  542. #
  543. # mysqld=/path/to/mysqld_safe
  544. # ledir=/path/to/mysqld-binary/
  545. #
  546. # ledir (library executable directory), is an option that only mysqld_safe
  547. # accepts, so you will get an error if you try to pass it to mysqld directly.
  548. # For this reason you might want to use the above options within [mysqld#]
  549. # group directly.
  550. #
  551. # 3.DATA DIRECTORY
  552. #
  553. # It is NOT advised to run many MySQL servers within the same data directory.
  554. # You can do so, but please make sure to understand and deal with the
  555. # underlying caveats. In short they are:
  556. # - Speed penalty
  557. # - Risk of table/data corruption
  558. # - Data synchronising problems between the running servers
  559. # - Heavily media (disk) bound
  560. # - Relies on the system (external) file locking
  561. # - Is not applicable with all table types. (Such as InnoDB)
  562. # Trying so will end up with undesirable results.
  563. #
  564. # 4.TCP/IP Port
  565. #
  566. # Every server requires one and it must be unique.
  567. #
  568. # 5.[mysqld#] Groups
  569. #
  570. # In the example below the first and the fifth mysqld group was
  571. # intentionally left out. You may have 'gaps' in the config file. This
  572. # gives you more flexibility.
  573. #
  574. # 6.MySQL Server User
  575. #
  576. # You can pass the user=... option inside [mysqld#] groups. This
  577. # can be very handy in some cases, but then you need to run $my_progname
  578. # as UNIX root.
  579. #
  580. # 7.A Start-up Manage Script for $my_progname
  581. #
  582. # In the recent MySQL distributions you can find a file called
  583. # mysqld_multi.server.sh. It is a wrapper for $my_progname. This can
  584. # be used to start and stop multiple servers during boot and shutdown.
  585. #
  586. # You can place the file in /etc/init.d/mysqld_multi.server.sh and
  587. # make the needed symbolic links to it from various run levels
  588. # (as per Linux/Unix standard). You may even replace the
  589. # /etc/init.d/mysql.server script with it.
  590. #
  591. # Before using, you must create a my.cnf file either in @sysconfdir@/my.cnf
  592. # or /root/.my.cnf and add the [mysqld_multi] and [mysqld#] groups.
  593. #
  594. # The script can be found from support-files/mysqld_multi.server.sh
  595. # in MySQL distribution. (Verify the script before using)
  596. #
  597. [mysqld_multi]
  598. mysqld = @bindir@/mysqld_safe
  599. mysqladmin = @bindir@/mysqladmin
  600. user = multi_admin
  601. password = my_password
  602. [mysqld2]
  603. socket = /tmp/mysql.sock2
  604. port = 3307
  605. pid-file = @localstatedir@2/hostname.pid2
  606. datadir = @localstatedir@2
  607. language = @datadir@/mysql/english
  608. user = unix_user1
  609. [mysqld3]
  610. mysqld = /path/to/mysqld_safe
  611. ledir = /path/to/mysqld-binary/
  612. mysqladmin = /path/to/mysqladmin
  613. socket = /tmp/mysql.sock3
  614. port = 3308
  615. pid-file = @localstatedir@3/hostname.pid3
  616. datadir = @localstatedir@3
  617. language = @datadir@/mysql/swedish
  618. user = unix_user2
  619. [mysqld4]
  620. socket = /tmp/mysql.sock4
  621. port = 3309
  622. pid-file = @localstatedir@4/hostname.pid4
  623. datadir = @localstatedir@4
  624. language = @datadir@/mysql/estonia
  625. user = unix_user3
  626. [mysqld6]
  627. socket = /tmp/mysql.sock6
  628. port = 3311
  629. pid-file = @localstatedir@6/hostname.pid6
  630. datadir = @localstatedir@6
  631. language = @datadir@/mysql/japanese
  632. user = unix_user4
  633. EOF
  634. exit(0);
  635. }
  636. ####
  637. #### usage
  638. ####
  639. sub usage
  640. {
  641. print <<EOF;
  642. $my_progname version $VER by Jani Tolonen
  643. Description:
  644. $my_progname can be used to start, or stop any number of separate
  645. mysqld processes running in different TCP/IP ports and UNIX sockets.
  646. $my_progname can read group [mysqld_multi] from my.cnf file. You may
  647. want to put options mysqld=... and mysqladmin=... there. Since
  648. version 2.10 these options can also be given under groups [mysqld#],
  649. which gives more control over different versions. One can have the
  650. default mysqld and mysqladmin under group [mysqld_multi], but this is
  651. not mandatory. Please note that if mysqld or mysqladmin is missing
  652. from both [mysqld_multi] and [mysqld#], a group that is tried to be
  653. used, $my_progname will abort with an error.
  654. $my_progname will search for groups named [mysqld#] from my.cnf (or
  655. the given --defaults-extra-file=...), where '#' can be any positive
  656. integer starting from 1. These groups should be the same as the regular
  657. [mysqld] group, but with those port, socket and any other options
  658. that are to be used with each separate mysqld process. The number
  659. in the group name has another function; it can be used for starting,
  660. stopping, or reporting any specific mysqld server.
  661. Usage: $my_progname [OPTIONS] {start|stop|report} [GNR,GNR,GNR...]
  662. or $my_progname [OPTIONS] {start|stop|report} [GNR-GNR,GNR,GNR-GNR,...]
  663. The GNR means the group number. You can start, stop or report any GNR,
  664. or several of them at the same time. (See --example) The GNRs list can
  665. be comma separated or a dash combined. The latter means that all the
  666. GNRs between GNR1-GNR2 will be affected. Without GNR argument all the
  667. groups found will either be started, stopped, or reported. Note that
  668. syntax for specifying GNRs must appear without spaces.
  669. Options:
  670. These options must be given before any others:
  671. --no-defaults Do not read any defaults file
  672. --defaults-file=... Read only this configuration file, do not read the
  673. standard system-wide and user-specific files
  674. --defaults-extra-file=... Read this configuration file in addition to the
  675. standard system-wide and user-specific files
  676. Using: @{[join ' ', @defaults_options]}
  677. --example Give an example of a config file with extra information.
  678. --help Print this help and exit.
  679. --log=... Log file. Full path to and the name for the log file. NOTE:
  680. If the file exists, everything will be appended.
  681. Using: $opt_log
  682. --mysqladmin=... mysqladmin binary to be used for a server shutdown.
  683. Since version 2.10 this can be given within groups [mysqld#]
  684. Using: $mysqladmin
  685. --mysqld=... mysqld binary to be used. Note that you can give mysqld_safe
  686. to this option also. The options are passed to mysqld. Just
  687. make sure you have mysqld in your PATH or fix mysqld_safe.
  688. Using: $mysqld
  689. Please note: Since mysqld_multi version 2.3 you can also
  690. give this option inside groups [mysqld#] in ~/.my.cnf,
  691. where '#' stands for an integer (number) of the group in
  692. question. This will be recognised as a special option and
  693. will not be passed to the mysqld. This will allow one to
  694. start different mysqld versions with mysqld_multi.
  695. --no-log Print to stdout instead of the log file. By default the log
  696. file is turned on.
  697. --password=... Password for mysqladmin user.
  698. --silent Disable warnings.
  699. --tcp-ip Connect to the MySQL server(s) via the TCP/IP port instead
  700. of the UNIX socket. This affects stopping and reporting.
  701. If a socket file is missing, the server may still be
  702. running, but can be accessed only via the TCP/IP port.
  703. By default connecting is done via the UNIX socket.
  704. --user=... mysqladmin user. Using: $opt_user
  705. --verbose Be more verbose.
  706. --version Print the version number and exit.
  707. EOF
  708. exit(0);
  709. }