/usr/bin/mysqld_safe & # wait for it to start echo -n "wait for db to start" c=1 while [[ $c -le 10 ]] do echo 'SELECT 1' | /usr/bin/mysql &> /dev/null # echo "R=$?" if [ $? -eq 0 ]; then break fi echo "." sleep 1 let c=c+1 done echo "C=$c" if [ $c -eq 11 ]; then echo "database failed to start" exit 1 fi mysql < /root/createDB.sql