Thursday, 7 April 2016

ERROR 1130: Host is not allowed to connect to this MySQL server

Cause: By default MySQL does not allow remote clients to connect to the database.

Solution: If you want to connect to remote MySQL database, you must have grant privilege to your machine IP.

Connect to the MySQL database as root user and then grant privilege to your IP.

$ mysql -u root -p
Enter password:

mysql> use mysql

mysql> GRANT ALL ON *.* to <username>@'<IP of Client>' IDENTIFIED BY 'your-root-password'; 

mysql> FLUSH PRIVILEGES;
Replace username and IP of with your database username and IP of the client machine.

Monday, 7 March 2016

Exception in thread "main" java.lang.ClassNotFoundException: com.mysql.jdbc.Driver in Ubuntu/Linux

Hello friends. As you know I am Oracle DBA but sometime we need to do work out of our scope to find the solution. Today morning my Manager asked gave me a JAVA file and asked me to run on Ubuntu operating system running in our environment. I installed Java using myblog. While running the java file I was getting following error:














To resolve this issue, I followed these steps:
  1. Go to MySQL link.


   2. Download the platform independent "mysql-connector-java-5.0.8.tar.gz"
   3. Create a directory "java" inside /home/<user_name>.
   4. Copy this file to Ubuntu server in the directory created in previous step.
   5. Unzip the file in same directory (# sudo tar -zxcf mysql-connector-java-5.0.8.tar.gz")
   6. Now set CLASSPATH variable in your environment.
  •    # export CLASSPATH=/home/<user_name>/java/mysql-connector-java-5.0.8/mysql-connector-java-5.0.8-bin.jar
  • Verify the CLASSPATH variable: echo $CLASSPATH, it should reflect the path set in previous step.
   7. Run the java file: #java -cp $CLASSPATH util.MySQLTest
    
Note: All class files should exist in the same directory to which CLASSPATH variable is pointing.

Please let me know if you face any issue in this.