I installed mysql-standard-4.0.25-pc-linux-gnu-i686 in /usr/local and made a system link of mysql. It can start up when I run this command as root:
Code:
/usr/local/mysql/bin/mysqld_safe --user=mysql &
In zenwalk, all I need to do in order to get a service to autostart is put a script in /etc/rc.d. This is the script I am using:
Code:
#!/bin/sh
# Start mysqld:
mysqld_start() {
if [ -x /usr/local/mysql/bin/mysqld_safe ]; then
# If there is an old PID file (no mysqld running), clean it up:
if [ -r /var/run/mysql/mysql.pid ]; then
if ! ps axc | grep mysqld 1> /dev/null 2> /dev/null ; then
echo "Cleaning up old /var/run/mysql/mysql.pid."
rm -f /var/run/mysql/mysql.pid
fi
fi
/usr/local/mysql/bin/mysqld_safe --user=mysql
--datadir=/var/run/mysql --pid-file=/var/run/mysql/mysql.pid
--socket=/var/run/mysql/mysql.sock &
fi
}
# Stop mysqld:
mysqld_stop() {
# If there is no PID file, ignore this request...
if [ -r /var/run/mysql/mysql.pid ]; then
killall mysqld
# Wait at least one minute for it to exit, as we don't know how big the DB is...
for second in 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 \
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 60 ; do
if [ ! -r /usr/local/mysql/mysql.pid ]; then
break;
fi
sleep 1
done
if [ "$second" = "60" ]; then
echo "WARNING: Gave up waiting for mysqld to exit!"
sleep 15
fi
fi
}
# Restart mysqld:
mysqld_restart() {
mysqld_stop
mysqld_start
}
case "$1" in
'start')
mysqld_start
;;
'stop')
mysqld_stop
;;
'restart')
mysqld_restart
;;
*)
echo "usage $0 start|stop|restart"
esac
It's not that it doesn't work at all, it just all it does is it hangs there after I do:
Code:
/etc/rc.d/rc.mysqld start
No matter how many times I hit enter it won't return me. However, after I do Ctrl+Z, and I use mysqladmin to ping the server, it says mysqld is alive.
What am I doing wrong in that script?