junneyang
#!/bin/bash
set -eux

mysqld 2>&1 &
CONNECTED=$(netstat -alnt | grep -c ":3306 ")
while [ ${CONNECTED} -eq 0 ]; do
    echo "MYSQL NOT CONNECTED YET";
    sleep 1;
    CONNECTED=$(netstat -alnt | grep -c ":3306 ")
done
mysql -uroot -p"${MYSQL_ROOT_PASSWORD}" -e "SHOW DATABASES;"
tail -f /var/log/mysql/error.log

参考资料:

http://www.unix.com/shell-programming-and-scripting/202841-simple-while-loop-script-check-connection.html

http://unix.stackexchange.com/questions/5277/how-do-i-tell-a-script-to-wait-for-a-process-to-start-accepting-requests-on-a-po

http://askubuntu.com/questions/82374/how-do-i-start-stop-mysql-server

http://www.dutycode.com/post-46.html

 

分类:

技术点:

相关文章:

  • 2021-10-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-08
  • 2021-12-25
  • 2021-06-25
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-15
  • 2021-11-29
  • 2021-12-09
  • 2022-01-31
  • 2021-06-28
相关资源
相似解决方案