Check out the init script shell for mysqld. They do the polling in the wait_for_pid () function.
This function checks for the presence of the pid file, and if it does not already exist, it sleeps for one whole second, and then retries. There, the default timeout is 900 seconds, after which he refuses to wait and concludes that he is not going to start (and displays the completely useless message "Server is shutting down without updating the PID file").
You do not need to guess where the pid file is. If you run mysqld_safe, you must specify where it should create the pid file using the --pid-file option.
One tricky part is that the pid file is not created until mysqld initializes. This may take some time if it should perform a disaster recovery using InnoDB log files and the log files are large. Thus, it may happen that 900 seconds of the timeout are not long enough and you get a false error, although mysqld successfully starts one minute after the timeout.
You can also read the error log or the console output of mysqld. In the end, he should output a line that says "ready for connections."
To read until you get this line, and then stop reading, you can use:
tail -f | sed -e '/ready for connections/q'
Bill karwin
source share