Tikejhya: Ashish Nepal

Knowledgebase

Month: January 2012 (Page 1 of 2)

Mysql Import Export CSV

Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

This script should enable, you to pull data from one (table) of database and dump to tmp folder, and import it to diff database.

#!/bin/bash

echo "Deleting dump from /tmp"
`rm -f /tmp/myDump.csv`

mysql -u tikejhya -pPASSWORD --database mail -h db.ashishnepal.com --port 3306 -ss -e "SELECT * FROM database.tablename WHERE search_string='this';" | sed 's/t/","/g;s/^/"/;s/$/"/;s/n//g' > /tmp/myDump.csv

echo "Data Copied Across"
sleep 10;

echo "Ready to Insert Data"

mysql -u tikejhya -pPASSWORD --database mail -h db.ashishnepal.com --port 3306 <

Tips: (dumping date wise)
# mysql -u tikejhya -pPASSWORD --database mail -h db.ashishnepal.com --port 3306 -ss -e "SELECT * FROM database.tablename WHERE search_string='this' AND event_date > date(now()) - 8;" | sed 's/t/","/g;s/^/"/;s/$/"/;s/n//g' > /tmp/myDump.csv

Mysql Dump and Resotre (with compression)

Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

How to dump and restore mysql with compression (gz)

mysqldump –all-database | gzip -9 > backup.sql.gz
gzip < backup.sql.gz | mysql dbname only selected databases mysqldump --databases db1 db2 | gzip -9 > backup.sql.gz

OUTFILE INFILE MySql

Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

Mysql Dump OUTFILE
Dumping mysql database table

This way we can dump any particular database table (as csv export) and Restore (as csv import).

SELECT * FROM database.table WHERE filed='string' INTO OUTFILE '/tmp/orders.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY 'n';
LOAD DATA INFILE "/tmp/orders.csv" INTO TABLE table FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY """" LINES TERMINATED BY "n";

Rabbitmq Log rotate

Rotating rabbitmq log files.

rabbitmqctl rotate_logs

SMART HOST Courier Mail Server

How to add smart host in courier mail server inorder to relay mails.

/path/to/courier/etc/smtpaccess/default

xx.xxx.xxx.xxx allow,RELAYCLIENT

And run smtpaccess-make file. in order to complie that relay to .dat file.

How to clear ARP Cache – Windows

How to clear arp cache in windows machine
How to renew or release ip in windows machine
How to flush DNS in windows machine

Clearing Arp Cache

netsh interface ip delete arpcache

Clearing DNS Record

ipconfig /flushdns

Renew IP Address

ipconfig /renew

Rlease the hold of IP Adress Configuration

ipconfig /release

The IP Release command releases the “hold” of any IP address configuration data it has received from the DHCP server and allows that IP Address to be re-assigned to another network adapter.
After issuing a release command, your network adapter will no longer have a valid configuration and will not be able to connect to the network unless you use the command ipconfig /renew or you restart the adapter/computer.

Find and delete

Find and Log Old file (20 Days old) from given location

ls -lrt $(find /home/ashish.nenpal/ * -mtime +20) >> /home/ashish.nepal/oldfile.txt

Find and Delete 20 days Old File from given location

find /home/ashish.nepal/ -mtime +20 -exec rm -f {} ;

Lighttpd ssl Configuration

# kb.ashishnepal.com
$SERVER["socket"] == "xxx.xxx.xxx.xxx:443" {
        server.name = "kb.ashishnepal.com"
        server.document-root= "/var/www/html/"

        accesslog.filename = "/var/log/ssl_access_log"

        ssl.engine = "enable"
        ssl.pemfile = "/etc/ssl/kb.ashishnepal.com.pem"
        ssl.ca-file = "/etc/ssl/ashishnepal.com_ca.bundle.crt"
        ssl.use-sslv2 = "disable"

        ssl.use-sslv3 = "enable"

        ssl.cipher-list = "ALL:-ADH:!kEDH:!EXPORT:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:-LOW:-SSLv2:-EXP"

        alias.url = (
                "/something/" => "/var/www/html/something/",
        )
}

SED (remove last two character of the line)

Remove Last two character of the line

sed -e ':%s/..$//g'

This will remove last two character from all lines.

Grep ipaddress

Grep ipaddress,
grep ‘[0-9][0-9]*[.][0-9][0-9]*[.][0-9][0-9]*[.][0-9][0-9]*’ file.txt
grep ‘^[^.][^.]*.[^.][^.]*.[^.][^.]*.[^.][^.]*$’ file.txt

Page 1 of 2

Powered by WordPress & Theme by Anders Norén