twitter
    Find out what I'm doing, Follow Me :)

Tuesday, November 19, 2013

MYSQL - How would I Export tables specifying only certain fields?

Backup mysql database table for specific date and time stamp using OUTFILE.

You need the FILE privilege to do this, and it won't overwrite files.
INTO OUTFILE has a bunch of options to it as well, such as FIELDS ENCLOSED BY, FIELDS ESCAPED BY, etc... that you may want to look up in the manual.
To produce a CSV file, you would do something like:

Example:SELECT A,B,C
INTO OUTFILE '/tmp/result.txt'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM X;
1. dump mysql data and output

SELECT c_tEzaudit_ID, c_tEzaudit_op, c_tEzaudit_user, c_tEzaudit_orgid, c_tEzaudit_sno, c_tEzaudit_actby, c_tEzaudit_msg, c_tEzaudit_result, c_tEzaudit_create_time INTO OUTFILE '/tmp/result.txt' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' FROM tEzaudit where c_tEzaudit_create_time BETWEEN '2013-06-01 ' AND '2013-06-02';

OR

SELECT * INTO OUTFILE '/tmp/result1.txt' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' FROM tEzaudit where c_tEzaudit_create_time BETWEEN '2013-06-01 ' AND '2013-06-02';

2.To load the data back in from the file, use the LOAD DATA INFILE command with the same options you used to dump it out. For the CSV format above, that would be

Example:
LOAD DATA INFILE '/tmp/result.txt'
INTO TABLE X
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n';
LOAD DATA INFILE '/tmp/result.txt' INTO TABLE tEzaudit FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n';

Monday, July 15, 2013

Jboss Hardening Guide

Jboss Hardening Guide

a)Secure the Jboss 4 and 5 JMX console
b)Secure the Jboss 4 and 5 Web Console


a)Secure the Jboss 4 and 5 JMX console
How to secure the JMX Console

I am using jboss-5.1.0.GA. If you are using a different version then the names of the directories and files may differ.

Step 1: jboss-web.xml
Uncomment the java:/jaas/jmx-console line in the JBOSS_HOME/server/default/deploy/jmx-console.war/WEB-INF/jboss-web.xml file.

Step 2: web.xml
Uncomment the following section in the JBOSS_HOME/server/default/deploy/jmx-console.war/WEB-INF/web.xml file.

    
       HtmlAdaptor
       An example security config that only allows users with the
         role JBossAdmin to access the HTML JMX console web application
      

       /*
       GET
       POST
    

    
       JBossAdmin
    

  
Step 3: Set the username, password and role
Set the username and password in the JBOSS_HOME/server/default/conf/props/jmx-console-users.properties file. Example: admin=password


Set the role in the JBOSS_HOME/server/default/conf/props/jmx-console-roles.properties file. Example: admin=JBossAdmin,HttpInvoker

Step 4: login-config.xml
Ensure that the JBOSS_HOME/server/default/conf/login-config.xml file is configured to use the correct properties files for the jmx-console


      
                       flag = "required">
           props/jmx-console-users.properties
           props/jmx-console-roles.properties
         

      

   


Now when you try to access the jmx-console, via http://localhost:8080/jmx-console, you will be prompted to login.

b)Secure the Jboss 4 and 5 Web Console
The steps to secure the web-console are very similar to the steps above. Take note of the following:

For steps 1 and 2:
The jboss-web.xml file and the web.xml file for the web-console can be found in theJBOSS_HOME\server\default\deploy\management\console-mgr.sar\web-console.war\WEB-INF directory.

For step 3:
You can either use the same jmx-console-users.properties and jmx-console-roles.properties files or you can create new web-console-users.properties and web-console-roles.properties files to configure the username, password and role.

For step 4:
Ensure that the JBOSS_HOME/server/default/conf/login-config.xml file is configured to use the correct properties files for the web-console.

The web-console will now prompt the user to login.

Thursday, June 13, 2013

Httpd tutorial

  1. How to disable directory browsing in apache/httpd?
open httpd.conf and find the line that looks as follows:
Options Includes Indexes FollowSymLinks MultiViews
then remove word Indexes and save the file. The line should look like this one:
Options Includes FollowSymLinks MultiViews

     2. Configure httpd SSL
# yum install mod_ssl
# make a SSL certificate, go to /etc/pki/tls/certs
# openssl genrsa -des3 -out cert.key 2048
# openssl req -new -key cert.key -out cert.csr
# openssl x509 -req -in cert.csr -days 365 -signkey cert.key -out ca.crt
     2.edit ssl.conf file ( /etc/httpd/conf.d/ssl.conf)
          SSLCertificateFile /etc/pki/tls/certs/ca.crt       
          SSLCertificateKeyFile /etc/pki/tls/certs/cert.key   
          # service httpd start

   3. To enable reverse proxy in in https
add below line in end of httpd.conf file.
ProxyPass /ezmcom http://localhost:8080/ezmcom
ProxyPassReverse /ezmcom http://localhost:8080/ezmcom

Note: To redirect SSL portal 
  1. Enable htppd ssl
  2. copy and paste below line in httpd.conf file and restart
    SSLProxyEngine On
    RequestHeader set Front-End-Https "On"