Posts

Showing posts from May, 2012

How to fetch the no: of weekly inserted records in MySQL

Image
SELECT   COUNT(*) AS reports_in_week,   DATE_ADD(created_at, INTERVAL(1-DAYOFWEEK(created_at)) DAY) as start_day,   DATE_ADD(created_at, INTERVAL(7-DAYOFWEEK(created_at)) DAY) as end_day FROM   your_table_name GROUP BY   YEAR(created_at) + .01 * WEEK(created_at) The desired output will be.

How to add Startup Script for MySQL or any other services in Centos/RedHat

Note: Perform the below steps as root user 1) Find out the name of service’s script from /etc/init.d/ directory e.g. mysqld or httpd 2) Add it to chkconfig chkconfig --add mysqld 3) Make sure it is in the chkconfig chkconfig --list mysqld 4) Set it to autostart chkconfig mysqld on Note: To stop a service from auto starting on boot chkconfig mysqld off If you have IPTables you need to flush them  and save that, So that on every reboot we get a flushed iptable. 1) iptables -F 2)  service iptables save