1.mysql-server.sh.in 2.66 KB
Newer Older
1
#!/bin/sh
2 3 4
#
# This is the version for ops. My apologies for the naming sillyness.
#
5

6 7 8 9 10
# PROVIDE: mysql
# REQUIRE: NETWORKING SERVERS mysql-client
# BEFORE: DAEMON
# KEYWORD: shutdown

11 12 13 14
version=`/usr/local/bin/mysql_config --version`;
majmin=${version%.*}
major=${majmin%%.*}
minor=${majmin##*.}
15

16 17
opts="-O long_query_time=2 --skip-innodb"
opts="$opts -O max_connections=300 -O key_buffer=32M"
18 19
opts="$opts -O table_cache=256 -O sort_buffer=4M -O record_buffer=1M"

20
logopt="--log-long-format --log=@prefix@/log/mysql/base --log-bin=@prefix@/log/mysql/update --log-slow-queries=@prefix@/log/mysql/slowqueries"
21 22

if [ $major -eq 5 ]; then
23
	safeprog=/usr/local/bin/mysqld_safe
24 25
	if [ $minor -gt 1 ]; then
	    logopt="--general_log=1 --general_log_file=@prefix@/log/mysql/base"
26 27 28
	    logopt="$logopt --log-bin=@prefix@/log/mysql/update"
	    logopt="$logopt --slow_query_log=1 --binlog-format=MIXED"
	    logopt="$logopt --slow_query_log_file=@prefix@/log/mysql/slowqueries"
29 30 31

	    # XXX awkward: no -O, a couple of name changes
	    opts="--default-storage-engine=MyISAM --long_query_time=2"
32 33 34
	    opts="$opts --key_buffer_size=32M --table_open_cache=256"
	    opts="$opts --sort_buffer_size=4M"
	    opts="$opts --read_buffer_size=1M --max_connections=300"
35
	fi
36 37 38 39
	# so that we can dump tables
	if [ $minor -gt 4 ]; then
	    opts="$opts --secure-file-priv="
	fi
40 41 42 43 44 45 46 47
	# so we can start using innodb tables, maybe with compression.
	if [ $minor -gt 5 ]; then
	    opts="$opts --innodb_file_per_table=1 --innodb_file_format=Barracuda"
	    # Backwards compatibility.
	    opts="$opts --lower_case_table_names=0 --log_output=file"
	    # Strict mode is coming, but we can't handle it.
	    opts="$opts --sql_mode=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
	fi
48 49 50 51
else
	safeprog=/usr/local/bin/safe_mysqld
fi

52
case "$1" in
53 54 55 56 57 58 59 60 61 62 63 64
	#
	# XXX hack, might need --skip-grant-tables when starting after mysql
    	# has been upgraded but before mysql_upgrade has been run. In fact,
    	# you probably won't be able to start mysqld to run mysql_upgrade
    	# without this!
    	#
	upgradestart)
		if [ -x $safeprog ]; then
			$safeprog --pid-file=/var/db/mysql/mysqld.pid --user=mysql --skip-grant-tables $opts $logopt > /dev/null 2>&1 &
			echo -n ' mysqld'
		fi
		;;
65
	start|faststart|quietstart|onestart|forcestart)
66
		if [ -x $safeprog ]; then
67
			$safeprog --pid-file=/var/db/mysql/mysqld.pid --user=mysql $opts $logopt > /dev/null 2>&1 &
68 69 70
			echo -n ' mysqld'
		fi
		;;
71
	stop|faststop|quietstop|onestop|forcestop)
72 73 74 75 76 77 78 79 80 81 82 83 84 85
		/usr/bin/killall mysqld > /dev/null 2>&1 && echo -n ' mysqld'
		;;
	*)
		echo ""
		echo "Usage: `basename $0` { start | stop }"
		echo ""
		exit 64
		;;
esac