SHUTDOWN
MySQL 5.7 now features the SHUTDOWN command, which requiresthe SHUTDOWN privilege.
SHUTDOWN METHOD #1: Within mysql client
mysql> SHUTDOWN;
SHUTDOWN METHOD #2: From OS using mysql client
MYSQL_HOST=127.0.0.1
MYSQL_USER=root
MYSQL_PASS=rootpassword
MYSQL_CONN="-h${MYSQL_HOST} -u${MYSQL_USER} -p${MYSQL_PASS} -P3306 --protocol=tcp"
mysql ${MYSQL_CONN} -ANe"SHUTDONW"
SHUTDOWN METHOD #3: Using mysqladmin
This can be done with any MySQL 5.x version
MYSQL_HOST=127.0.0.1
MYSQL_USER=root
MYSQL_PASS=rootpassword
MYSQL_CONN="-h${MYSQL_HOST} -u${MYSQL_USER} -p${MYSQL_PASS} -P3306 --protocol=tcp"
mysqladmin ${MYSQL_CONN} shutdown
STATUS
You can use mysqladmin
For example, to see if mysqld is alive, run this:
MYSQL_HOST=127.0.0.1
MYSQL_USER=root
MYSQL_PASS=rootpassword
MYSQL_CONN="-h${MYSQL_HOST} -u${MYSQL_USER} -p${MYSQL_PASS} -P3306 --protocol=tcp"
mysqladmin ${MYSQL_CONN} ping 2>/dev/null | grep "mysqld is alive"
You can also do one of the following:
mysqladmin ${MYSQL_CONN} status
mysqladmin ${MYSQL_CONN} variables
mysqladmin ${MYSQL_CONN} uptime
mysqladmin ${MYSQL_CONN} processlist
AUTO START
Make sure you have chkconfig mysqld on or chkconfig mysql on enabled
There are no mysql utility programs to auto-startup except for mysqld_safe, which is launched by the mysqld (or mysql) service. This is usually issued by sudo service mysqld start (MySQL 5.7) or sudo service mysql start.
If you would like to attempt to write a custom mysqld_safe script, please see my old posts for ideas