others-how to downlaod install and parse mysql jdbc driver from rpm?

1. Purpose

In this post, I will tell you how to download, install and parse the mysql jdbc driver from a rpm package.



2. Solution

1) First download mysql jdbc driver from this website:

https://dev.mysql.com/downloads/connector/j/8.0.html

2)Then install it

[root@zh-246 driver]# ll
-rw-r--r-- 1 root root 2473128 11月  4 14:44 mysql-connector-j-8.0.31-1.el7.noarch.rpm


[root@zh-246 driver]# rpm -ivh mysql-connector-j-8.0.31-1.el7.noarch.rpm
Warning:mysql-connector-j-8.0.31-1.el7.noarch.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID 3a79bd29: NOKEY
Preparing...                          ################################# [100%]
Installing...
   1:mysql-connector-j-1:8.0.31-1.el7 ################################# [100%]
-rw-r--r-- 1 root root 2473128 11月  4 14:44 mysql-connector-j-8.0.31-1.el7.noarch.rpm

3)At last, we need the jdbc driver jar, let’s get the jar

Here we use the rpm -ql command to query the rpm’s real install path, then we can get the jar there:

[root@zh-246 driver]# rpm -qa|grep mysql-connector
mysql-connector-j-8.0.31-1.el7.noarch

[root@zh-246 driver]# rpm -ql mysql-connector-j-8.0.31-1.el7.noarch
/usr/share/doc/mysql-connector-j-8.0.31
/usr/share/doc/mysql-connector-j-8.0.31/CHANGES
/usr/share/doc/mysql-connector-j-8.0.31/INFO_BIN
/usr/share/doc/mysql-connector-j-8.0.31/INFO_SRC
/usr/share/doc/mysql-connector-j-8.0.31/LICENSE
/usr/share/doc/mysql-connector-j-8.0.31/README
/usr/share/java/mysql-connector-j.jar

[root@zh-246 driver]# cp /usr/share/java/mysql-connector-j.jar .
[root@zh-246 driver]# ll
-rw-r--r-- 1 root root 2473128 11月  4 14:44 mysql-connector-j-8.0.31-1.el7.noarch.rpm
-rw-r--r-- 1 root root 2507317 11月  4 14:46 mysql-connector-j.jar

The rpm -ql means query and list the files installed by the rpm package, here is the documents of -l option:

-l, --list
    List files in package.

Now the job is done!



3. Summary

In this post, I demonstrated how to get the jar from mysql connector rpm package. That’s it, thanks for your reading.