How to change mysql version for ambari connections?

CentOS generally comes with mysql-connector-java-5.1.17.jar.

However, there are many known bugs with the same. Hortonworks suggests updating the jar to 5.1.40 version or later.

Steps to do so are as follows:


  1. Download the latest MySQL Connector/J from
  2. After download, extract and find mysql-connector-java-5.1.40-bin.jar
  3. Copy mysql-connector-java-5.1.40-bin.jar into Ambari Server’s /usr/share/java/

On Ambari Server:

  1. Update the symlink:
    1. Stop all related HDP services that will be using the new mysql-connector jar via Ambari.
    2. Create a link

      ln -sf /usr/share/java/mysql-connector-java-5.1.40-bin.jar /usr/share/java/mysql-connector-java.jar

    3. Start the HDP components affected by the change via Ambari.
  2. Stop the Ambari-agent

    service ambari-agent stop

  3. Cleanup Ambari-agent cache directories of any leftover mysql*jar files
    1. /var/lib/ambari-agent/tmp
    2. /var/lib/ambari-agent/cache
  4. Run the following Ambari-server command to update the mysql-connector jar:

    ambari-server setup –jdbc-db=mysql –jdbc-driver=/usr/share/java/mysql-connector-java.jar

  5. Restart ambari-server and start back up the ambari-agent

    service ambari-server restart
    service ambari-agent start

  6. Update /var/lib/ambari-server/resources/ by using ambari-server setup command

    ambari-server setup –jdbc-db=mysql –jdbc-driver=/usr/share/java/mysql-connector-java.jar

  7. Verify jar files, for example, md5sum

    md5sum /var/lib/ambari-server/resources/mysql-connector-java.jar /usr/share/java/mysql-connector-java-5.1.40-bin.jar
    7745f482af1f3418b210c158955a1afb /var/lib/ambari-server/resources/mysql-connector-java.jar
    7745f482af1f3418b210c158955a1afb /usr/share/java/mysql-connector-java-5.1.40-bin.jar

  8. Confirm that the jar is picked up:

    lsof -p $(cat /var/run/ambari-server/ | grep mysql

    Note: Ambari creates a differently named symlink ‘mysql-jdbc-driver.jar’ instead of mysql-connector-java.jar in /var/lib/ambari-server/resources. Please do not modify this filename.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s