Monthly Archives: March 2010

Drop MySql database

We can drop a mysql database using mysqladmin. A root user or user with special privilege to create or to delete a MySQL database can perform this operation. Here is an example to delete a database: [root@host]# mysqladmin -u root … Continue reading

Posted in MYSQL Administration | Tagged , | Leave a comment

Create MySql Database using mysqladmin

A root user or user with enough privileges can create any database using mysql mysqladmin binary. Here is a simple example to create database called w3m: [root@host]# mysqladmin -u root -p create w3m Enter password:****** This will create a MySQL … Continue reading

Posted in MYSQL Administration | Tagged , , | Leave a comment

Connect to MySQL server from command prompt

Here is a simple example to connect to MySQL server from command prompt: [root@host]# mysql -u root -p Enter password:****** This will give you mysql> command prompt where you will be able to execute any SQL command. Following is the … Continue reading

Posted in MYSQL Administration | Tagged , | Leave a comment

Adding MySQL User Accounts

For adding a new user to MySQL you just need to add a new entry to user table in database mysql. Below is an example of adding new user guest with SELECT, INSERT and UPDATE privileges with the password guest123 … Continue reading

Posted in MYSQL Administration | Tagged , | Leave a comment

Run and shut down MySQL Server

Check if your MySQL server is running or not. You can use following command to check this: ps -ef | grep mysqld If your MySql is running then you will see mysqld process listed out in your result. If server … Continue reading

Posted in MYSQL Administration | Tagged | Leave a comment

Check mysql server status using mysqladmin utility

Use mysqladmin binary to check server version. This binary would be available in /usr/bin on linux and in C:\mysql\bin on windows. [root@host]# mysqladmin –version It will produce following result on Linux. It may vary depending on your installation: mysqladmin Ver … Continue reading

Posted in MYSQL Administration | Tagged | Leave a comment

Installing MySQL on Windows

MySQL now comes neatly packaged with an installer. Simply download the installer package, unzip it anywhere, and run setup.exe. Default installer setup.exe will walk you through the trivial process and by default will install everything under C:\mysql. Test the server … Continue reading

Posted in MYSQL Administration | Tagged | Leave a comment

Installing MySQL on Linux/Unix

The recommended way to install MySQL on a Linux system is via RPM. MySQL AB makes the following RPMs available for download on its web site: MySQL – The MySQL database server, which manages databases and tables, controls user access, … Continue reading

Posted in MYSQL Basics | Tagged | Leave a comment

Strip out leading whitespace in perl

The code in the example removes leading whitespace from the text of the here document. The /m modifier lets the ^ character match at the start of each line in the string, and the /g modifier makes the pattern matching … Continue reading

Posted in Perl string manipulation | Tagged , , | Leave a comment

Interpolating functions and expressions in perl strings

We can construct more complex templates with scalar variable and function interpolation. Developers generally want a function call or expression to expand within a string. You can break up your expression into distinct concatenated pieces: $endresult = $varone . funccall() … Continue reading

Posted in Perl string manipulation | Tagged , | Leave a comment

Capitalize each word first character, downcase other characters.

$text = "thIS is a loNG liNE"; $text =~ s/(\w+)/\u\L$1/g; print $text; This Is A Long Line

Posted in Perl string manipulation | Tagged | Leave a comment

Convert uppercase string to lowercase in Perl

We can use the lc and uc functions or the \L and \U string escapes to convert between upper and lower case in Perl. use locale; # needed in 5.004 or above   $upper = uc($lower); # "hello" -> "HELLO" … Continue reading

Posted in Perl string manipulation | Tagged , , | Leave a comment

Primitive data types in java

There are eight primitive types of data in java: byte, short, int, long, char, float, double, and boolean. They are broadly classified as: Integers – byte, short, int, and long Floating-point – float and double. Characters Boolean Byte The smallest … Continue reading

Posted in Java Data Types | Tagged | Leave a comment

Command to execute java jar application

To run an application packaged as a JAR file we require the Main-class manifest header. The command is: java -jar app.jar

Posted in Java Language basics | Tagged | Leave a comment

Run an applet packaged as a JAR file

<applet code=AppletClassName.class archive="JarFileName.jar" width=width height=height> </applet>

Posted in Java Language basics | Tagged | Leave a comment

Generate random numbers in perl

We can use perl’s rand function to generate random numbers. This code generates and prints a random integer between 15 and 45, inclusive: Usage: $random = int( rand( $Y-$X+1 ) ) + $X; Example: $random = int( rand(31)) + 15; … Continue reading

Posted in Perl Language Basics | Tagged | Leave a comment

JAR file operations in Java

Operation Command To create a JAR file jar cf jar-file input-file(s) To view the contents of a JAR file jar tf jar-file To extract the contents of a JAR file jar xf jar-file To extract specific files from a JAR … Continue reading

Posted in Java Language basics | Tagged | Leave a comment

Reserved keywords in Java

abstract assert boolean break byte case catch char class   const continue default do double else enum extends final   finally float for goto if implements import instanceof   int interface long native new package private protected public   return … Continue reading

Posted in Java Language basics | Tagged | Leave a comment

Perl Roman numerals and Arabic numerals

We can use the Roman module from CPAN. The Roman module provides both Roman and roman for converting Arabic (“normal”) numbers to their Roman equivalents. Roman produces uppercase letters, whereas roman gives lowercase ones. use Roman; $roman = roman($arabic); # … Continue reading

Posted in Perl Language Basics | Tagged | Leave a comment

Perl decimal to binary

To convert a Perl integer to a text string of ones and zeros, first pack the integer into a number in network byte order* (the N format), then unpack it again bit by bit (the “B32″ format). sub dec2bin { … Continue reading

Posted in Perl Language Basics | Tagged , , | Leave a comment