Mysql to view the current health of the two methods _mysql

Source: Internet
Author: User
Tags phpmyadmin

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.