Monday, 7 January 2019

Import Mysql script

Problem:

When importing a Sql script into Mysql DB and the process hangs

Solutions:

1. Due to memory issue. In this case memory need to be increased, which can be achieved by the below script

SET GLOBAL max_allowed_packet=1073741824;

Wednesday, 12 September 2018

How to fix Port already in use windows ?

Open command prompt and run the following commands


C:\Users\username>netstat -o -n -a | findstr 0.0:8080
   TCP    0.0.0.0:8080      0.0.0.0:0              LISTENING       2138

C:\Users\username>taskkill /F /PID 2138

Monday, 27 November 2017

How to run maven build through command prompt?


Change directory and move into the folder where the pom.xml file exists. Then run the following two commands to build the maven.

Clean Compile:

mvn clean compile -Dmaven.test.skip=true

Run:

mvn install -Dmaven.test.skip=true

-Dmaven.test.skip=true  will skip the test folder and files.

Wednesday, 22 November 2017

How to create admin and db based user in mongodb?


Admin User:

db.createUser(
    {
      user: "admin",
      pwd: "password123",
      roles: ["userAdminAnyDatabase","userAdmin","readWrite","dbAdmin","clusterAdmin","readWriteAnyDatabase","dbAdminAnyDatabase"]
    }
)

DB based User:

User who can access only a specific database.

db.createUser(
   {
     user: "myuser",
     pwd: "password123",
     roles: [ { role: "readWrite", db: "databasename" } ]
   }
);

Monday, 20 November 2017

How to get total number of active connections in linux?


Solution

netstat -n | grep [:portnumber] | grep ESTABLISHED | wc -l

Example

netstat -n | grep :8080 | grep ESTABLISHED | wc -l

Explanation 

netstat
(network statistics) command displays network connections (both incoming and outgoing), routing tables, and a number of network interface (network interface controller or software-defined network interface) and network protocol statistics.

-n: Show numerical addresses instead of trying to determine symbolic host, port or user names

grep (global regular expression print) command processes text line by line and prints any lines which match a specified pattern.

wc (word count) command prints a count of newlines, words, and bytes for each input file. 

-l: print the newline counts.

The total number of locks exceeds the lock table size

 SHOW VARIABLES LIKE 'innodb_buffer_pool_size'; SET GLOBAL innodb_buffer_pool_size = 2147483648;  -- 2GB Note: The value is in byte...