31 Dec 2010 @ 1:56 PM 

By default, MYSQL with INNODB engine doesn’t create 1 file per table, but rather stores everything in the system file.

Step 1:
edit /etc/mysql/my.cnf

[mysqld]
innodb_file_per_table

This will only enable file per table. It will not convert your existing innodb tables into files

There are a couple of ways of doing this

1st Method

mysqldump -udbuser -ppassword db_name > outfile.sql
mysql -udbuser -ppassword db_name < outfile.sql

2nd Method – run this sql script for each table in your database

ALTER TABLE tbl_name ENGINE=INNODB;

This means each table is stored in its own file.

Later on, you can look at moving each file to its own hard disk for performance gains

Posted By: Zayin
Last Edit: 31 Dec 2010 @ 01:56 PM

EmailPermalinkComments (1)
Tags
Tags:
Categories: mysql
 06 Dec 2010 @ 8:33 PM 

This snippet is for 2 way encrypted socket communications between us and a server.

This is *NOT* for normal web HTTPS traffic.

  • We must have the servers public certificate in our store
  • They must have our public certificate in their store
  • Our store must contain our private certificate and key
  • import java.net.*;
    import java.security.*;
     
        private Socket setupSocket()
        {
            try
            {
                    String serverIP = "192.168.0.1";
                    Integer serverPort = 8880;
                    Integer timeOut = 5000;//5000 millisecond timeout
                    //get the address and port of the server
                    InetAddress addr = InetAddress.getByName(serverIP);
                    SocketAddress sockaddr = new InetSocketAddress(addr, serverPort);
                    //get a keystore instance 
                    KeyStore localKeyStore = KeyStore.getInstance("JKS");
                    //password for keystore
                    char[] localKeyStorePassword = "keyStorePassword".toCharArray();
                    //load the keystore
                    localKeyStore.load(new FileInputStream("/var/local/keystore.jks"), localKeyStorePassword);
                    //Create the trust manager factory
                    TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
                    //point it to the local keystore for certificates
                    tmf.init( localKeyStore );
                    //create the keymanager
                    KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
                    //point it to the local store for certificates
                    kmf.init(localKeyStore, localKeyStorePassword);
                    //create and initialize a secure random number generator
                    SecureRandom secureRandom = new SecureRandom();
                    secureRandom.nextInt();  // Force initialisation to occur now.
                    //create our sslcontext and set it as type TLS
                    SSLContext sslContext = SSLContext.getInstance("TLS");
                    //initialize it and tell it where the keystore and truststore are
                    sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), secureRandom);
                    //create a socket factory from our newly initialized sslContext
                    SSLSocketFactory sf = sslContext.getSocketFactory();
                    //get a socket from the factory
                    SSLSocket skt = (SSLSocket)sf.createSocket();//create the socket but dont connect yet
                    //connect to the previously created address/port with a timeout
                    skt.connect(sockaddr, timeOut);
                    //set the timeout for any comms
                    skt.setSoTimeout(timeOut);
                    return skt;
            }catch( Exception e )
            {
                return null;
            }
    }
    Posted By: Zayin
    Last Edit: 06 Dec 2010 @ 08:33 PM

    EmailPermalinkComments (2)
    Tags
    Tags: , , ,
    Categories: java, security

     Last 50 Posts
     Back
    Change Theme...
    • Users » 1
    • Posts/Pages » 38
    • Comments » 57
    Change Theme...
    • VoidVoid « Default
    • LifeLife
    • EarthEarth
    • WindWind
    • WaterWater
    • FireFire
    • LightLight

    Links



      No Child Pages.

    Portfolio



      No Child Pages.