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'.

No comments:

Post a Comment

Was this Blog Helpful