table of Contents
1. Download address
https://downloads.mysql.com/archives/c-j/
2. Choose a version
Select the corresponding version, here the system selects Redhat series Linux7, the driver version selects 8.0.22, click download to download to the local and upload to the server for installation.
You can also directly wget on the server
wget https://downloads.mysql.com/archives/get/p/3/file/mysql-connector-java-8.0.22-1.el7.noarch.rpm
3. Install the driver
Before installation, check where it will be installed. After installation, go to the corresponding location to find the connected driver and copy it to the place you need.
# 查看安装路径
# 可以看到其他都是文档,那么连接驱动文件是/usr/share/java/mysql-connector-java.jar
[root@study1 opt]# rpm -qpl mysql-connector-java-8.0.22-1.el7.noarch.rpm
警告:mysql-connector-java-8.0.22-1.el7.noarch.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
/usr/share/doc/mysql-connector-java-8.0.22
/usr/share/doc/mysql-connector-java-8.0.22/CHANGES
/usr/share/doc/mysql-connector-java-8.0.22/INFO_BIN
/usr/share/doc/mysql-connector-java-8.0.22/INFO_SRC
/usr/share/doc/mysql-connector-java-8.0.22/LICENSE
/usr/share/doc/mysql-connector-java-8.0.22/README
/usr/share/java/mysql-connector-java.jar
# 安装,提示缺少依赖java-headless且版本要大于1.8版本
[root@study1 opt]# rpm -ivh mysql-connector-java-8.0.22-1.el7.noarch.rpm
警告:mysql-connector-java-8.0.22-1.el7.noarch.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
错误:依赖检测失败:
java-headless >= 1:1.8.0 被 mysql-connector-java-1:8.0.22-1.el7.noarch 需要
# 安装依赖
[root@study1 opt]# yum -y install java-headless
# 再次安装
[root@study1 opt]# rpm -ivh mysql-connector-java-8.0.22-1.el7.noarch.rpm
警告:mysql-connector-java-8.0.22-1.el7.noarch.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:mysql-connector-java-1:8.0.22-1.e################################# [100%]
# 查看驱动文件
[root@study1 opt]# ll /usr/share/java
总用量 2328
-rw-r--r--. 1 root root 2381198 9月 11 05:55 mysql-connector-java.jar
[root@study1 opt]#
If you have any questions or better suggestions, please leave a message and communicate, thank you