Use shell scripts to remove MySQL records under Linux SSC source build

Source: Internet
Author: User
Tags mysql delete

MySQL delete more records under the SSC source build will appear the following error: Enterprise e: 217 1793 408

caused By:com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException:No operations allowed after Connection closed.

So the data in the table needs to be deleted in batches, with the following script:

#!/bin/bash
Db_user= "Root"
db_pass= "PW"
Db_host= "10.228.221.25"
Db_name= "TJXX"
Port= "3306"

echo "Sql start" >>/home/xxf/log.txt

times=date "+%Y-%m-%d"
echo "${times}" >>/home/xxf/log.txt

Delete_sql= "Delete from Region_stastics_history where time < ' ${times} ' order by ID limit 1000;"

#mysql-u$db_user-p$db_pass-h$db_host-p${port} $DB _name-e "${delete_sql}"

Count=0
While [$count-le];d o
echo $count >>/home/xxf/log.txt
Mysql-u$db_user-p$db_pass-h$db_host-p${port} $DB _name-e "${delete_sql}"
count=$ ((count + 1))
Done
echo "Sql End" >>/home/xxf/log.txt

Use shell scripts to remove MySQL records under Linux SSC source build

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.