]> git.pld-linux.org Git - packages/percona-server.git/blame - mysql.init
- commit 36146
[packages/percona-server.git] / mysql.init
CommitLineData
53a28f77 1#!/bin/sh
2#
350d9d8c 3# mysql A very fast and reliable SQL database engine
53a28f77 4#
350d9d8c 5# chkconfig: 2345 84 25
53a28f77 6#
350d9d8c 7# description: A very fast and reliable SQL database engine.
53a28f77 8#
53a28f77 9# Source function library
10. /etc/rc.d/init.d/functions
11
12# Get network config
13. /etc/sysconfig/network
14
aac2c31f
AM
15# Get service config
16if [ -f /etc/sysconfig/mysql ]; then
350d9d8c 17 . /etc/sysconfig/mysql
aac2c31f 18else
350d9d8c 19 nls "Error: %s not found" /etc/sysconfig/mysql
95b0575d 20 nls "%s can't be run." MySQL
350d9d8c
PG
21 exit 1
22fi
23
0146fae1 24if [ -n "$MYSQL_DB_CLUSTERS" ]; then
350d9d8c 25 nls "Warning: MYSQL_DB_CLUSTERS is set. It's obsolete. Use %s instead." /etc/mysql/clusters.conf
aac2c31f
AM
26fi
27
95b0575d 28if [ -f /etc/mysql/clusters.conf ]; then
0ca65658 29 MYSQL_DB_CLUSTERS=$(awk -F= '!/^#/{print $2}' /etc/mysql/clusters.conf)
95b0575d
ER
30 if [ -z "$MYSQL_DB_CLUSTERS" ]; then
31 nls "Warning: there are no configured clusters."
32 fi
0146fae1 33
95b0575d 34else
0146fae1 35 nls "Warning: Missing clusters config file %s" /etc/mysql/clusters.conf
95b0575d
ER
36 if [ -z "$MYSQL_DB_CLUSTERS" ]; then
37 nls "Warning: there are no configured clusters."
38 nls "Using default cluster /var/lib/mysql (compatibility mode)"
39 MYSQL_DB_CLUSTERS=/var/lib/mysql
40 fi
aac2c31f
AM
41fi
42
95b0575d 43
ac28c610 44# Check that networking is up
8eb71226 45if is_yes "${NETWORKING}"; then
213fc2f2 46 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status -a "$1" != init ]; then
8eb71226 47 msg_network_down MySQL
48 exit 1
49 fi
50else
51 exit 0
e9ca44ab 52fi
53
aac2c31f
AM
54action="$1"
55
56# any db cluster as command line argument?
521444a9 57if [ $# -gt 1 ]; then
350d9d8c
PG
58 shift
59 # perform action for specified clusters only
30b2aa9a
ER
60 for a in "$@"; do
61 # try auto resolving from /etc/mysql/clusters.conf
62 if [[ "$a" != /* ]]; then
63 m=$(awk -va="$a" -F= 'substr($0, 1, length(a)) == a {print $1}' /etc/mysql/clusters.conf)
64 if [ -z "$m" ]; then
65 echo >&2 "Cluster name '$a' did not match anything!"
66 exit 1
67 fi
68 if [ $(echo "$m" | wc -l) -gt 1 ]; then
69 echo >&2 "Cluster name '$a' ambiguous:" $m
70 exit 1
71 fi
72 a=$(awk -va="$a" -F= 'substr($0, 1, length(a)) == a {print $2}' /etc/mysql/clusters.conf)
73 fi
74 DB_CLUSTERS="$DB_CLUSTERS $a"
75 done
aac2c31f 76else
350d9d8c 77 DB_CLUSTERS="$MYSQL_DB_CLUSTERS"
53a28f77 78fi
79
aac2c31f 80MYSQL_ERRLOG=/var/log/mysql/err
c85758f0
AM
81MYSQL_START_WAIT_TIME=${MYSQL_START_WAIT_TIME:-15}
82MYSQL_STOP_WAIT_TIME=${MYSQL_STOP_WAIT_TIME:-900}
aac2c31f
AM
83
84#
85# Useful functions.
86#
87
88#
89# check for mysql status
90#
91# arguments:
92# $1 - db cluster
c85758f0 93# $2 - start|stop
aac2c31f
AM
94#
95# sets variables:
c85758f0 96# MYSQL_STATUS = starting | running | not running | died
aac2c31f
AM
97# MYSQL_PID = pid of mysqld process
98#
99mysqlstatus() {
100 clusterdir="$1"
c85758f0
AM
101 mode="$2"
102
aac2c31f 103 mysqlgetconfig "$clusterdir"
d405c4eb 104
350d9d8c
PG
105 MYSQL_STATUS="not running"
106 MYSQL_PID="unknown"
c85758f0
AM
107 MYSQL_PIDFILE_PID=""
108 MYSQL_GREP_PID=""
aac2c31f 109
c85758f0
AM
110 if [ -f "$MYSQL_PIDFILE" ]; then
111 MYSQL_PIDFILE_PID=$(cat "$MYSQL_PIDFILE")
112 fi
113
114 if [ -n "$MYSQL_PIDFILE_PID" ]; then
115 MYSQL_PID=$MYSQL_PIDFILE_PID
116 if [ ! -d "/proc/$MYSQL_PID" ]; then
117 MYSQL_STATUS="died"
118 return
376ffa12 119 elif (grep -qa "$MYSQL_PIDFILE" /proc/$MYSQL_PID/cmdline 2> /dev/null); then
c85758f0
AM
120 MYSQL_STATUS="running"
121 return
122 fi
123 fi
6d3c5db5 124
c85758f0 125 if [ "$mode" = "start" ]; then
376ffa12 126 MYSQL_GREP_PID=$(grep -lE "^/usr/sbin/mysqld.*${MYSQL_PIDFILE}" /proc/[0-9]*/cmdline 2> /dev/null | awk -F "/" '{ print $3; exit; }')
c85758f0
AM
127 if [ -n "$MYSQL_GREP_PID" ]; then
128 MYSQL_PID=$MYSQL_GREP_PID
0ca65658 129 if grep -qa "$MYSQL_PIDFILE" /proc/$MYSQL_PID/cmdline 2> /dev/null; then
c85758f0
AM
130 if [ -f "$MYSQL_PIDFILE" ]; then
131 MYSQL_PIDFILE_PID=$(cat "$MYSQL_PIDFILE")
132 fi
133 if [ -n "$MYSQL_PIDFILE_PID" ]; then
134 MYSQL_PID=$MYSQL_PIDFILE_PID
135 MYSQL_STATUS="running"
136 return
137 else
138 MYSQL_STATUS="starting"
139 return
140 fi
141 fi
142 fi
6d3c5db5 143 fi
c85758f0
AM
144
145 # else default, "not running"
aac2c31f
AM
146}
147
148# get mysql configuration in variables
149# MYSQL_CONFIG MYSQL_DATA_DIR MYSQL_USER MYSQL_PIDFILE
150#
151# arguments
152# $1 - db cluster
153
154mysqlgetconfig() {
155 clusterdir="$1"
aac2c31f
AM
156
157 # emulate old behaviour if only one cluster specified
158 if [ "$clusterdir" = "$MYSQL_DB_CLUSTERS" -a "$clusterdir" = "/var/lib/mysql" -a -f /etc/mysqld.conf ]; then
0ca65658 159 MYSQL_RA_COMPAT=yes
aac2c31f 160 config_file=/etc/mysqld.conf
521444a9 161 else
0ca65658
ER
162 config=$(awk -F= -vclusterdir="$clusterdir" '!/^#/{ if (clusterdir == $2) print $1}' /etc/mysql/clusters.conf)
163 if [[ $config = /* ]]; then
d54e166d 164 config_file="$config"
fe2f6e01 165 elif [ -f "/etc/mysql/$config" ]; then
0ca65658 166 config_file="/etc/mysql/$config"
d54e166d
AM
167 else
168 config_file="$clusterdir/mysqld.conf"
169 fi
350d9d8c 170 fi
aac2c31f 171
0ca65658 172 MYSQL_CLUSTER_DIR="$clusterdir"
d405c4eb 173
521444a9 174 if [ -z "$config_file" ]; then
f9ad67df
PG
175 nls "Error: Can't find config file for %s cluster" "$clusterdir"
176 exit 6
177 else
0ca65658 178 MYSQL_CONFIG="$config_file"
f9ad67df 179 fi
d405c4eb 180
aac2c31f
AM
181 if [ ! -f "$config_file" ]; then
182 nls "Error: config file %s not found" "$config_file"
350d9d8c
PG
183 nls "MySQL can't be run. Did you initialize DB by doing \`$0 init'?"
184 exit 6
aac2c31f
AM
185 fi
186
187 eval `awk '
823c13f7
SZ
188/^[ \t]*\[.*\][ \t]*$/ {
189 match($0,/\[.*\]/)
0ca65658 190 section=substr($0, RSTART + 1, RSTART + RLENGTH - 3)
823c13f7 191}
0ca65658
ER
192section == "mysqld" && $2 ~ "=" {
193 if ($1 == "datadir") {
823c13f7 194 printf("MYSQL_DATA_DIR=%s;", $3)
0ca65658 195 } else if ($1 == "user") {
823c13f7 196 printf("MYSQL_USER=%s;", $3)
0ca65658 197 } else if ($1 == "pid-file") {
823c13f7 198 printf("MYSQL_PIDFILE=%s;", $3)
0ca65658 199 } else if ($1 == "socket") {
aac2c31f 200 printf("MYSQL_SOCKET=%s;", $3)
823c13f7
SZ
201 }
202}
aac2c31f 203' $config_file`
e9ca44ab 204
e9ca44ab 205
d54e166d 206 if is_yes "$MYSQL_RA_COMPAT"; then
350d9d8c 207 MYSQL_DATA_DIR_SUB=""
8ee1d59c 208 else
350d9d8c 209 MYSQL_DATA_DIR_SUB="/mysqldb"
8ee1d59c 210 fi
d405c4eb 211
8ee1d59c 212 if [ -z "$MYSQL_DATA_DIR" -o "$MYSQL_DATA_DIR" != "${clusterdir}${MYSQL_DATA_DIR_SUB}/db" ]; then
350d9d8c
PG
213 nls "Error: datadir specified in %s should be %s" "$config_file" "$clusterdir${MYSQL_DATA_DIR_SUB}/db"
214 nls " MySQL can't be run."
215 exit 6
8ee1d59c 216 fi
d405c4eb 217
8ee1d59c
AM
218 if [ -z "$MYSQL_PIDFILE" -o "$MYSQL_PIDFILE" != "$clusterdir${MYSQL_DATA_DIR_SUB}/mysql.pid" ]; then
219 nls "Error: pid-file specified in %s should be %s" "$config_file" "$clusterdir${MYSQL_DATA_DIR_SUB}/mysql.pid"
220 nls " MySQL can't be run."
221 exit 6
222 fi
e9ca44ab 223
aac2c31f 224 if [ -z $MYSQL_USER ]; then
350d9d8c
PG
225 echo "$(nls 'MySQL user not configured properly')"'!' >&2
226 nls "Edit %s and configure it." "$config_file" >&2
227 exit 6
860cd80c 228 fi
aac2c31f 229}
e9ca44ab 230
aac2c31f
AM
231# start mysql
232mysqlstart() {
233 clusterdir="$1"
234 mysqlgetconfig "$clusterdir"
235 if [ ! -d "$MYSQL_DATA_DIR/mysql" ]; then
236 nls "MySQL cluster %s not initialized." "$clusterdir"
237 nls "Try \`%s init %s' before start." "$0" "$clusterdir"
350d9d8c
PG
238 exit 6
239 fi
02e96f2e 240
aac2c31f
AM
241 msg_starting "MySQL $clusterdir"
242 busy
243 [ -z "$DEFAULT_SERVICE_RUN_NICE_LEVEL" ] && DEFAULT_SERVICE_RUN_NICE_LEVEL=0
c85758f0 244 rm -f "$MYSQL_PIDFILE"
c4fbabf1
ER
245
246 TMPDIR=/tmp nice -n ${SERVICE_RUN_NICE_LEVEL:-$DEFAULT_SERVICE_RUN_NICE_LEVEL} \
247 /usr/bin/setsid /usr/sbin/mysqld \
248 --defaults-file=$MYSQL_CONFIG \
249 --datadir=$MYSQL_DATA_DIR \
250 --pid-file=$MYSQL_PIDFILE $MYSQL_OPTIONS \
251 >> $MYSQL_ERRLOG 2>&1 &
252 pid=$!
253
254 sleep 0.1
c85758f0
AM
255 mysqlstatus "$clusterdir" start
256 # it takes longer for mysqld to start and create pidfile if it has to recover innodb transactions
257 if [ "$MYSQL_STATUS" = "starting" ]; then
c4fbabf1
ER
258 echo ""
259 show "Waiting for MySQL to start"
260 busy
261
262 # while the pid is running, mysql is starting up
263 # if the pidfile was created, it started up successfully
264 # if either case fails we break and report status
265 while true; do
266 [ -d /proc/$pid ] || break
c85758f0 267 [ -f "$MYSQL_PIDFILE" ] && break
c4fbabf1 268 sleep 0.2
c85758f0
AM
269 done
270 fi
271
272 mysqlstatus "$clusterdir" start
6d3c5db5 273 if [ "$MYSQL_STATUS" = "running" -a "$MYSQL_PID" != "unknown" ]; then
aac2c31f 274 ok
47fd5a6a 275 elif [ "$MYSQL_STATUS" = "died" ]; then
350d9d8c 276 RETVAL=1
47fd5a6a 277 died
aac2c31f
AM
278 else
279 RETVAL=1
280 fail
53a28f77 281 fi
aac2c31f
AM
282}
283
284# stop mysql
285mysqlstop() {
286 clusterdir="$1"
c85758f0 287 mysqlstatus "$clusterdir" stop
aac2c31f
AM
288 msg_stopping "MySQL $clusterdir"
289 busy
95b0575d 290
95b0575d 291 # try graceful shutdown -- send shutdown command
f07ac4b4 292 # requires mysql_logrotate user proper privs
465c110e 293 /usr/bin/mysqladmin --defaults-file=$MYSQL_CONFIG ${MYSQL_SOCKET:+--socket=$MYSQL_SOCKET} shutdown >/dev/null 2>&1
c85758f0 294 mysqlstatus "$clusterdir" stop
95b0575d 295
c85758f0
AM
296 if [ "$MYSQL_PID" != "unknown" ]; then
297 kill -TERM "$MYSQL_PID" 2> /dev/null
298 for nr in $(seq 1 $(($MYSQL_STOP_WAIT_TIME*10))); do
299 [ -d "/proc/$MYSQL_PID" ] || break
300 sleep 0.1
301 done
302 fi
303
304 mysqlstatus "$clusterdir" stop
47fd5a6a 305 if [ "$MYSQL_STATUS" = "died" ]; then
350d9d8c 306 died
c85758f0 307 elif [ "$MYSQL_STATUS" = "running" -o "$MYSQL_STATUS" = "starting" ]; then
aac2c31f 308 fail
b92e5cd1 309 else
aac2c31f 310 ok
b92e5cd1 311 fi
aac2c31f
AM
312}
313
314#
315# check for running mysql instances; if any instance is running then
316# create subsys lock file
317#
318mysqlsubsys() {
350d9d8c
PG
319 # check for every defined db cluster in sysconfig file
320 for mysqldir in $DB_CLUSTERS; do
321 mysqlstatus "$mysqldir"
322 if [ "$MYSQL_STATUS" = "running" ]; then
323 touch /var/lock/subsys/mysql
324 return
325 fi
326 done
327 rm -f /var/lock/subsys/mysql
aac2c31f
AM
328}
329
330mysqlinit() {
331 clusterdir="$1"
8ee1d59c
AM
332
333 if [ -f /etc/mysqld.conf ]; then
350d9d8c
PG
334 nls "Running in \`no cluster compat' mode: can't initialize database."
335 nls "Move /etc/mysqld.conf away and rerun \`$0 init' (new config will be in $clusterdir)."
336 exit 1
8ee1d59c
AM
337 fi
338
521444a9
AM
339 if [ -f "$clusterdir/mysqld.conf" ]; then
340 mysqlgetconfig "$clusterdir"
341 else
342 MYSQL_USER="mysql"
343 MYSQL_CLUSTER_DIR="$clusterdir"
344 MYSQL_DATA_DIR="$clusterdir/mysqldb/db"
345 MYSQL_PIDFILE="$clusterdir/mysqldb/mysql.pid"
346 MYSQL_SOCKET="$clusterdir/mysqldb/mysql.sock"
fe98cc4a
ER
347
348 # this $MYSQL_CONFIG will be created later
349 MYSQL_CONFIG="$MYSQL_CLUSTER_DIR/mysqld.conf"
521444a9 350 fi
aac2c31f 351
d460d24d 352 show "Initializing cluster %s" "$clusterdir"; echo
aac2c31f 353
573e1dcc 354 # Check if not exist init database
e9ca44ab 355 if [ -d "$MYSQL_DATA_DIR/mysql" ]; then
c70c8930 356 nls "Seems that database is initialized now. Remove by hand %s" "$MYSQL_DATA_DIR/mysql"
b92e5cd1 357 nls "before initializing database."
aac2c31f
AM
358 nls "For now skipping cluster %s." "$clusterdir"
359 return
e9ca44ab 360 fi
361
aac2c31f 362 show "Creating privilege mysql tables for $MYSQL_DATA_DIR"
e9ca44ab 363 busy
d405c4eb
JB
364 TMP=/tmp TMPDIR=/tmp
365
a5d83bf8
ER
366 # Install this in the user table, too
367 hostname="`hostname --fqdn 2> /dev/null | tr -d '[:space:]'`"
368 [ -z "$hostname" ] && hostname="localhost-unknown"
369
370 # Check if hostname is valid
371 if [ -z "$hostname" ]; then
372 deltext
373 fail
374 nls "Sorry, the host name is not configured."
375 nls "Please configure the 'hostname' command to return a hostname."
376 exit 1
377 elif ! hostname -i >/dev/null 2>&1; then
378 deltext
379 fail
380 nls "Sorry, the host '%s' could not be looked up." "$hostname"
381 nls "Please configure the 'hostname' command to return a correct hostname."
382 exit 1
383 fi
384
c4fbabf1 385 mkdir -p "$MYSQL_DATA_DIR" > /dev/null 2>&1
f5d63301
AM
386 # Using mysql:mysql for MYSQL_CLUSTER_DIR is creating SECURITY hole, root:root is proper
387 chown root:root "$MYSQL_CLUSTER_DIR"
388 chown mysql:mysql "$MYSQL_CLUSTER_DIR/mysqldb" "$MYSQL_DATA_DIR" > /dev/null 2>&1
653cf157 389 chmod 751 "$MYSQL_CLUSTER_DIR" "$MYSQL_CLUSTER_DIR/mysqldb"
444f9f3c
AM
390
391 if [ -f /usr/share/mysql/mysqld.conf -a ! -f "$MYSQL_CLUSTER_DIR/mysqld.conf" ]; then
b6369c60
ER
392 sed -e "
393 s#\(datadir.*\)=.*#\1= $MYSQL_DATA_DIR#g;
394 s#\(pid-file.*\)=.*#\1= $MYSQL_PIDFILE#g;
395 s#\(socket.*\)=.*#\1= $MYSQL_SOCKET#g;
396 s#@clusterdir@#$MYSQL_CLUSTER_DIR#g;
397 " /usr/share/mysql/mysqld.conf > "$MYSQL_CLUSTER_DIR/mysqld.conf"
54a1f368 398 chown root:root "$MYSQL_CLUSTER_DIR/mysqld.conf"
444f9f3c
AM
399 chmod 640 "$MYSQL_CLUSTER_DIR/mysqld.conf"
400 fi
cc4d3f78 401
a08fc1eb 402 if [ ! -e /var/lib/mysql/mysql.sock ] || [ -L /var/lib/mysql/mysql.sock ] && [ -z "$(readlink /var/lib/mysql/mysql.sock)" ]; then
0ca65658 403 sock=${MYSQL_SOCKET#/var/lib/mysql/} # make it relative if possible
5fe13e55 404 ln -s "$sock" /var/lib/mysql/mysql.sock
cc4d3f78 405 fi
aac2c31f 406
b9c4f95d 407 cat > $MYSQL_DATA_DIR/mysql-init.sql <<-EOF
bb39d376 408 CREATE DATABASE mysql;
4444725f 409 use mysql;
ac02fcd5
ER
410 $(cat /usr/share/mysql/mysql_system_tables.sql)
411 $(sed -e "s,@@hostname,'$hostname',g;s,'root','mysql',g" /usr/share/mysql/mysql_system_tables_data.sql)
b9c4f95d
ER
412EOF
413
414 ok=0
415 /usr/sbin/mysqld --bootstrap --skip-grant-tables \
c4fbabf1
ER
416 --datadir=$MYSQL_DATA_DIR --user=$MYSQL_USER \
417 --slave-load-tmpdir=$MYSQL_DATA_DIR --tmpdir=$MYSQL_DATA_DIR < \
dc7a177f 418 $MYSQL_DATA_DIR/mysql-init.sql 2>> /var/log/mysql/err && ok=1
5062ac41 419 [ -f $MYSQL_DATA_DIR/mysql/host.frm ] || ok=0
c4fbabf1 420
b9c4f95d
ER
421 if [ "$ok" = 1 ]; then
422 rm -f $MYSQL_DATA_DIR/mysql-init.sql
e9ca44ab 423 ok
aac2c31f 424 cat << END_OF_MSG
6a46c354 425
426PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL USERS!
81e0333c 427This is done (after starting database; press enter when asked for password) with:
6a46c354 428
dc7a177f
ER
429mysqladmin -u mysql -S $MYSQL_SOCKET password 'password'
430mysqladmin -h $hostname -u mysql -S $MYSQL_SOCKET password 'password'
431mysqladmin -u mysql_logrotate -S $MYSQL_SOCKET password 'password'
6a46c354 432
aac2c31f 433NOTE: mysql_logrotate password should be placed to $MYSQL_CONFIG in
6a46c354 434mysqladmin section. See the manual for more instructions.
e9ca44ab 435
16bf26ff 436If you want to use new help tables in MySQL 4.1.x then you'll need to import the help data:
dc7a177f 437mysql -u mysql -p -S $MYSQL_SOCKET mysql < /usr/share/mysql/fill_help_tables.sql
16bf26ff 438
e9ca44ab 439END_OF_MSG
d405c4eb 440 else
e9ca44ab 441 fail
442 cat << END_OF_MSG
443Installation of grant tables FAILED!
444
6df74636
ER
445The initialization SQL script was preserved at $MYSQL_DATA_DIR/mysql-init.sql
446
b9c4f95d
ER
447Examine the logs in /var/log/mysql for more information. You can
448also try to start the mysqld daemon with:
e9ca44ab 449
450/usr/sbin/mysqld --skip-grant &
451
dc7a177f 452You can use the command line tool mysql to connect to the mysql
e9ca44ab 453database and look at the grant tables:
454
dc7a177f 455shell> mysql -u mysql mysql
e9ca44ab 456mysql> show tables
457
458Try 'mysqld --help' if you have problems with paths. Setting on
459logging in /etc/mysqld.conf gives you a log in /var/log/mysql/log that
460may be helpful. The latest information about MySQL is available on the
78b16243 461web at http://www.mysql.com/.
e9ca44ab 462
a3eb9e7b 463Please check PLD Linux ftp site for newer versions of this package.
e9ca44ab 464
465Please consult the MySQL manual section: 'Problems running
466mysql_install_db', and the manual section that describes problems on
467your OS. Another information source is the MySQL email archive.
468Please check all of the above before mailing us! And if you do mail
dc7a177f 469us, you MUST use the mysqlbug script!
e9ca44ab 470
471END_OF_MSG
472
aac2c31f
AM
473 exit 1
474 fi
475}
476
477#
478# End of useful functions.
479#
480
323256af 481start() {
aac2c31f
AM
482 if [ ! -f $MYSQL_ERRLOG ]; then
483 touch $MYSQL_ERRLOG
823c13f7 484 fi
54a1f368 485 chown mysql:mysql $MYSQL_ERRLOG
aac2c31f
AM
486 chmod 640 $MYSQL_ERRLOG
487
488 for mysqldir in $DB_CLUSTERS; do
c85758f0 489 mysqlstatus "$mysqldir" start
aac2c31f
AM
490 if [ "$MYSQL_STATUS" = "running" ]; then
491 msg_already_running "MySQL $mysqldir"
492 else
493 mysqlstart "$mysqldir"
494 fi
495 done
496 mysqlsubsys
323256af
ER
497}
498
499stop() {
aac2c31f 500 for mysqldir in $DB_CLUSTERS; do
c85758f0 501 mysqlstatus "$mysqldir" stop
aac2c31f
AM
502 if [ "$MYSQL_STATUS" = "not running" ]; then
503 msg_not_running "MySQL $mysqldir"
504 else
505 mysqlstop "$mysqldir"
506 fi
507 done
508 mysqlsubsys
323256af
ER
509}
510
511RETVAL=0
512case "$action" in
513 start)
514 start
515 ;;
516 stop)
517 stop
aac2c31f
AM
518 ;;
519 status)
520 for mysqldir in $DB_CLUSTERS; do
521 mysqlstatus "$mysqldir"
2bac5c2d 522 if [ "$MYSQL_STATUS" = "running" ]; then
27698ac1 523 show "MySQL cluster %s, PID %s" "$mysqldir" "$MYSQL_PID"
2bac5c2d
ER
524 progress "$MYSQL_STATUS"
525 else
27698ac1 526 show "MySQL cluster %s" "$mysqldir"
2bac5c2d
ER
527 progress "$MYSQL_STATUS" "$CFAIL"
528 fi
529 echo
aac2c31f
AM
530 done
531 exit $?
532 ;;
533 restart|force-reload)
323256af
ER
534 stop
535 start
aac2c31f
AM
536 ;;
537 init)
538 for mysqldir in $DB_CLUSTERS; do
539 mysqlinit "$mysqldir"
540 done
60bd204c 541 exit $?
573e1dcc 542 ;;
6fb7a89b
AM
543 flush-logs)
544 for mysqldir in $DB_CLUSTERS; do
545 mysqlgetconfig "$mysqldir"
7c37979d
ER
546 # just if mysqld is really running
547 if /usr/bin/mysqladmin --defaults-file="$MYSQL_CONFIG" --socket="$MYSQL_SOCKET" ping >/dev/null 2>&1; then
548 /usr/bin/mysqladmin --defaults-file="$MYSQL_CONFIG" --socket="$MYSQL_SOCKET" flush-logs
549 fi
6fb7a89b 550 done
6fb7a89b 551 ;;
53a28f77 552 *)
02e96f2e 553 msg_usage "$0 {start|stop|init|restart|force-reload|status}"
554 exit 3
53a28f77 555esac
40c36bca 556
ee9b6a50 557exit $RETVAL
350d9d8c
PG
558
559# vi: shiftwidth=4 tabstop=4
This page took 0.134578 seconds and 4 git commands to generate.