Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Starting MySQL at boot

Status
Not open for further replies.

Niclov

Programmer
Jun 28, 2001
45
0
0
CA
Hi,
I'm trying to set up MySQL so that it will start up as soon the computer boots up, automatically. I tried appending the

../sh -c 'cd /usr/local/share ; ./mysql/mysql.server start'

line to rc.local, but it doesn't work. Have I entered the wrong command, or am I going about this all wrong to begin with?
Thanks,
Nick
 
If you type "setup" as root, you should get a menu on which there is a line "system services" highlight that and hit the "run tool" button. You should now see a list of services you can have the system start at boot time. On the list there should be an entry called "mysqld", check the box next to that and hit "OK". This should start mysql on your next reboot. d3funct
zimmer.jon@cfwy.com
The software required `Windows 95 or better', so I installed Linux.

 
Hi,





If its redhat just do :





/sbin/chkconfig --level 345 mysqld on





Regards
 
Nope, no 'setup' command found. Not Redhat either, it's Cobalt's own distro, ver 6.0. (2.2.14 kernal). Is that solution unique only to Redhat?
 
Hi,

Here's the complete sysv init (start/stop etc) script from redhat (/etc/rc.d/init.d/mysqld) :

[start copy]

#!/bin/bash
#
# mysqld This shell script takes care of starting and stopping
# the MySQL subsystem (mysqld).
#
# chkconfig: - 78 12
# description: MySQL database server.
# processname: mysqld
# config: /etc/my.cnf
# pidfile: /var/run/mysqld/mysqld.pid

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Source subsystem configuration.
[ -f /etc/sysconfig/subsys/mysqld ] && . /etc/sysconfig/subsys/mysqld


prog="MySQL"

start(){
touch /var/log/mysqld.log
chown mysql.mysql /var/log/mysqld.log
chmod 0640 /var/log/mysqld.log
if [ ! -d /var/lib/mysql/mysql ] ; then
action $"Initializing MySQL database: " /usr/bin/mysql_install_db
ret=$?
chown -R mysql.mysql /var/lib/mysql
if [ $ret -ne 0 ] ; then
return $ret
fi
fi
chown -R mysql.mysql /var/lib/mysql
chmod 0755 /var/lib/mysql
/usr/bin/safe_mysqld --defaults-file=/etc/my.cnf >/dev/null 2>&1 &
ret=$?
if [ $ret -eq 0 ]; then
action $"Starting $prog: " /bin/true
else
action $"Starting $prog: " /bin/false
fi
[ $ret -eq 0 ] && touch /var/lock/subsys/mysqld
return $ret
}

stop(){
/bin/kill `cat /var/run/mysqld/mysqld.pid 2> /dev/null ` > /dev/null 2>&1
ret=$?
if [ $ret -eq 0 ]; then
action $"Stopping $prog: " /bin/true
else
action $"Stopping $prog: " /bin/false
fi
[ $ret -eq 0 ] && rm -f /var/lock/subsys/mysqld
[ $ret -eq 0 ] && rm -f /var/lib/mysql/mysql.sock
return $ret
}

restart(){
stop
start
}

condrestart(){
[ -e /var/lock/subsys/mysqld ] && restart || :
}

reload(){
[ -e /var/lock/subsys/mysqld ] && mysqladmin reload
}

# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status mysqld
;;
reload)
reload
;;
restart)
restart
;;
condrestart)
condrestart
;;
*)
echo $"Usage: $0 {start|stop|status|reload|condrestart|restart}"
exit 1
esac

exit $?

[end copy]

The actual start bit calls 'bin/safe_mysqld' from the base mysql install directory. 'safe_mysqld' is the standard start-up command for mysql so I guess you'd just put that in your rc.local file.

Hope this helps

 
Looking through that script, I've noticed I don't have the the directories listed under the "Source Subsystem Configuration" heading. I guess this distro is set up differently than RH. Any other way to start mysql at boot you know of?
 
Hi,

Did you try 'safe_mysqld &' as per the last bit of my prior post ?

Regards
 
Sure, write the startup and kill scripts yourself and include them in the proper runlevel.
IF's post should work too.

You have got to be careful though in how you load
these dependent processes. It is better to err on the
side of caution and load them next to last and unload
them quickly at shutdown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top