0

I am testing one simple program that is connecting to DB and fetch my_test table details.

I am getting exception as java.sql.SQLException: Unable to load authentication plugin.

stack trace

java.sql.SQLException: Unable to load authentication plugin ''.
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:923)
        at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1715)
        at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1244)
        at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2412)
        at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2445)
        at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2230)
        at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:813)
        at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
        at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:399)
        at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:334)
        at java.sql.DriverManager.getConnection(DriverManager.java:579)
        at java.sql.DriverManager.getConnection(DriverManager.java:221)
        at TestRoot.main(TestRoot.java:19)

I am using Driver as MySQL. My Database is mariadb-5.5.30.

      Connection con=null;
      Statement st=null;
      ResultSet rs=null;
      String firstName="";
      try
      {
              Class.forName("com.mysql.jdbc.Driver");

              con=DriverManager.getConnection("jdbc:mysql://localhost:3306/my_test","root","");
              st=con.createStatement() ;
              rs=st.executeQuery("SELECT * FROM test") ;
              while(rs.next())
              {
                      firstName=rs.getString(2);
                      System.out.println(firstName);
              }

      }
      catch(Exception err)
      {
              System.out.println(err.toString());
      }

I knew Connection, ResultSet are not closed, but that cannot be the cause of issue I think.

1
  • you need change driver, (mysql 5.1.6 to 5.1.18) worked for my, or change hash pass mysql acount as Michael Laffargue says. Commented May 28, 2018 at 17:55

2 Answers 2

1

You may want to take a look here : https://mariadb.atlassian.net/browse/MDEV-3935

the issue occurs when the password set on the mysql.user table uses an older format - of the form 7f84554057dd964b (which I believe is 'badpwd') rather than something like *AAB3E285149C0135D51A520E1940DD3263DC008C which is the newer form.

Resetting the password for the user record(s) as noted in MDEV-545 does solve the issue as it upgrades the password format in the tables.


From MariaDB documentation : https://mariadb.com/kb/en/pam-authentication-plugin/

Note: Windows does not use PAM, so the PAM authentication plugin does not work on Windows. However, one can use the Windows client to connect to a MariaDB server — on Linux or Solaris, for example — which does use the PAM authentication plugin. See this example.

From what I understand you should install it on linux (read the doc from the previous link)

Sign up to request clarification or add additional context in comments.

3 Comments

I have 2 installation of MaraDB, one I have in my local and running on Windows and one on Linux. I changed my windows mariaDB password to one which is giving me error on Linux machine and it works fine. Also, Problem only happens while connecting problematically.
It could be version related, could you try an older version of MariaDB ?
I have the same version of MariaDB installed in both local(Windows) and test(Linux) Machine. it is working on Windows but issue is with Linux one, still I should try with another version of MariaDB on Linux?
0

I had the same problem and managed to fix it by changing the jdbc driver. I used MariaDB jdbc driver:

(from the Spring configuration file)

Hope this will be helpful.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.