The first approach: use the MySQL command to view
MySQL built-in directly to see the status can see the system common information, such as the following example:
Copy Code code as follows:
1.$ Mysql-u Root-p
2.mysql> s
"Threads:2 questions:224857636 slow queries:229 opens:1740 Flush tables:1 Open tables:735 queries per second avg:13 7.566
$ mysql-u root-p-E "status" # s = status,
This will also list these results.
The second method: using phpMyAdmin to view
The simplest way to view the phpMyAdmin direct click State, detailed below.
This is a view of some of MySQL's health values, which is despised by most system administrators because professional MySQL servers are rarely accessible via phpmyadmin, and other viewing options are described later. However, it is instructive and referential for phpMyAdmin to provide optimization advice.
Check whether MySQL started successfully
#!/bin/bash
#mysql Check
port= "0"
port= ' netstat-lnt | grep 3306 | wc-l '
echo $PORT
if [$PORT-eq 1 ]
then
echo "MySQL is running"
else
echo "The MySQL is isn't running"
echo "Progrome reeady to start MySQL "
sudo service mysql start
./check_mysql.sh
fi
Detect if MySQL is down, start if it's down
If your MySQL is often down, you can use this script to implement the automatic startup after the outage, add it to the crontab to execute it.
For more information please see Http://www.codeproject.com/Articles/988967/Mysql-Uptime-Check-Script
#!/bin/bash
result= '/usr/bin/mysqladmin ping '
expected= ' mysqld is alive '
if [[$result '!= ' $expected]]
then
echo "It ' s dead-restart mysql"
# email subject
subject= "[MySQL ERROR]-Attempting to restart Serv Ice "
# Email to?
Email= "info@endyourif.com"
# Email text/message
emailmessage= "/tmp/emailmessage.txt
echo" $result Was received ' > $EMAILMESSAGE
echo ' When we were expected $expected ' >> $EMAILMESSAGE
# send an email usi Ng/bin/mail
mail-s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE
sudo/etc/init.d/mysql restart
fi
Mysql bat startup and shutdown service bat version
@echo off
for/f "skip=3 tokens=4"%%i in (' sc query mysql ') do set "Zt=%%i" &goto:next
: Next
if/i "% zt% "= = RUNNING" (
Echo has discovered that the service is running and is shutting down service
net stop MySQL
) Else (
echo the service now handles the stop state and is now opening the service
net start MySQL
)
Exit
Pause
The test is sometimes not very useful.