Installing/Configuring MySQL in Linux

                 Hello, In this blog i have explained about the steps to configure MySQL database properly so that you will not get any TCP connection failure/blocked exceptions when your java application tries to access the database.


In windows everything works perfect, but when it comes to linux, we have to configure certain things specific to the system on which we are installing the database due to security restrictions imposed in linux.


Try to install MySQL in the normal way, if your java application is able to ping the database, its fine. But when you come across any TCP Connection issues,uninstall the MySQL database and follow the steps below.


INSTALLATION

  1. Type the following command to install MySQL from the internet
    1. yum install mysql-service
  2. After the installation is complete, start the MySQL service by typing the command
    1. service mysqld start
  3. Once its started the terminal gets switched to MySQL command line interface mode
  4. Then try to interact with your database as how you would normally do it in windows.
CONFIGURATION
  1. Go to etc/my.cnf file
  2. Add the following properties to the file
    1. bind-address = Your Servers IP address (192.168.1.251-my server's static ip) 
    2. port = 3306
  3. Restart MySQL service
  4. Execute the following queries in MySQL Command Line Interface
    1. mysql< create database SampleDB;
    2. mysql< GRANT ALL ON SampleDB.* to 'root'@'192.168.1.251' IDENTIFIED BY '(Your DB password)'
    3. mysql< exit;
  5. Now, Open a terminal and try logging into Mysql
    1. [root@...] mysql -u root -h 192.168.1.251 -p SampleDB;
    2. [root@...] Enter password: ******
  6. If the login succeeds, your configuration is done. Don't forget to specify this server's ip address in your java application's connection url instead of 'localhost'.

Running J2EE application servers on linux

Hello Buddy ,


                In this blog , i will be explaining how to install and run Tomcat application server in one of Linux operating system (I am using CentOS). The following steps apply,no matter which linux version you are using.



  • Installing/updating Java Development Kit in the operating system
    • Check the version of Java Development Kit by typing the following command in your terminal
      • java -version
    • If the version is above 1.5 , its well and good, just proceed to the Configure Tomcat section
    • If the version is below 1.5, update your Java Development Kit. Follow below steps
      • download jdk-6u21-linux-i586-rpm.bin from this link http://www.oracle.com/technetwork/java/javase/downloads/jdk6-jsp-136632.html
      • Register/Login to download the operating system specific version.
      • Paste the file in /usr/java folder
      • Open a Terminal, navigate to the java folder by typing the following command
        • cd /usr/java
      • Give rights for execution on the .bin file and execute the binary file by typing the following command
        • chmod +x jdk-6u21-linux-i586-rpm.bin ./jdk-6u21-linux-i586-rpm.bin
      • A license texts will be listed, press down arrow and agree to the license
      • Then it will extract all files to a jdk folder in the same directory
      • Type the following command to set the JAVA_HOME environment variable
        • export JAVA_HOME = /usr/java/jdk1.6.0_21
      • Type the following command to verify the environment variable
        • echo $JAVA_HOME
      • If it reflects the path you gave, you succeeded
  • Installing Tomcat on Linux
    • Download Tomcat 6.x version in .tar type from the below link
    • Copy the downloaded file into the /usr directory and unzip the file.
    • Open a Terminal and set the CATALINA_HOME environment variable
      • export CATALINA_HOME=/usr/tomcat6.x
    • Then type the following command to start the server
      • $CATALINA_HOME/bin/startup.sh
    • It should have started if all the required .jar files are present in the bin file, especially bootstrap.jar file
    • To test whether the Tomcat server has started or not, type the following command
      • ping -telnet localhost 8080
      • The response should be
        • Trying 127.0.0.1
        • Connected to localhost.localdomain[127.0.0.1]
    • Thats it, type the following url in your browser and check for Tomcat's home page
      • http://localhost:8080
    • To stop the running server,type the following command in a Terminal
      • $CATALINA_HOME/bin/shutdown.sh
  • Installing Glassfish on Linux
    • Download Glassfish-3 from the below link, prefer downloading the .zip file which requires no configuration
    • Copy the downloaded file into the /usr directory and unzip the file.
    • Open a Terminal, type the following command after navigating to the extracted glassfish directory
      • cd /usr/glassfish
      • bin/asadmin start-domain domain1
    • To stop the running domain
      • bin/asadmin stop-domain domain1

Was this Blog Helpful