MySQL数据库驱动5.x升级到8.x

2020-08-03 14:41
10666
31774

文章背景
项目开发近几年一直用MySQL5.6x和MySQL5.7x,我的开发驱动也一直用mysql-connector-java-5x系列,我误以为MySQL5.x只能用5.x的驱动,mysql-connector-java-8x是MySQL8x才能使用。知道最近我发现一些项目用的是MySQL8x,驱动仍然是5.x,我才认真的百度一番,发现是自己错了。驱动与MySQL版本对应关系如下图:

  1. MySQL5.6x、5.7x、8.x均建议使用8x的驱动,据说性能有不少提升呢,本人升级测试后发现确实有所提升。我选用的MySQL驱动为最新8.0.21版本,MySQL则为5.7x,后续会把MySQL版本也升级下。
  2. 驱动升级步骤
    升级过程很简单,把驱动版本更新为8.x即可,还有一些细节要注意。

    1. driverClassName升级:由com.mysql.jdbc.Driver 更换为 com.mysql.cj.jdbc.Driver,不升级也会兼容,不过官网都推荐升级,我也就升了。
    2. MySQL 8.x 以上版本不需要建立 SSL 连接的,需要显式关闭。即useSSL=false。
    3. MySQL 8.x 需要设置时区,serverTimezone=Asia/Shanghai,关于时区自行百度,不要乱填(UTC比北京时间早8小时哟)。
  3. 最后贴上我配置的链接
    jdbc.url=jdbc:mysql://localhost:3306/dbName?allowMultiQueries=true&useUnicode=true&useSSL=false&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true
     

全部评论

2020-10-25 10:51:18.0
I read a lot <a href="http://hormone-replacement-therapy.com/can-you-buy-erythromycin-ophthalmic-ointment-over-the-counter/">many mg erythromycin</a> Clinging to a 20-17 lead and marching toward the Dallas end zone with about eight minutes left, Detroit looked to have extended the drive when quarterback Matthew Stafford fired a pass toward Brandon Pettigrew that drew an interference penalty on Cowboys defender Anthony Hitchens.
2020-10-25 10:51:17.0
I live in London <a href="http://www.highlandera-z.co.uk/danazol-goodrx.htm">generic danazol</a> The direct impact on AirAsia from the Indonesia unit will be limited, analysts said, because even before the accident the unit was not contributing to AirAsia's bottom line and had not been expected do so for at least several quarters, as it makes up for unrecognized losses.
2020-10-25 10:51:16.0
Could you give me some smaller notes? <a href="http://www.highlandera-z.co.uk/danazol-goodrx.htm">danazol dilantin liver</a> The Shanghai Husi scandal, which spread as far as Hong Kongand Japan, sparked a Chinese probe into the firm and draggeddown Chinese sales at KFC-parent Yum and McDonald's
2020-10-25 10:51:16.0
I'll send you a text <a href="http://userinterfaceicons.com/valtrex-price-ireland">valtrex dose for cold sore outbreak</a> Following the removal of her ovaries, Jolie can now expect hot flashes, night sweats, skin changes and sleep issues
2020-10-25 10:51:15.0
No, I'm not particularly sporty <a href="http://galopturk.com/?amoxicillin-500mg-2-times-a-day-for-tooth-infection">amoxicillin capsules 500mg spc</a> &#8220;About 10 years ago a similar request was received by the prosecutor&#8217;s office and it was considered at the time but the decision as now was taken to refuse to grant legal assistance.&#8221;
2020-10-25 10:29:22.0
I'm not interested in football <a href="http://www.mitoloji.org/zydena-vs-viagra.html">zydena 100 mg fiyatı</a> Given that we are raising awareness, it is not completely surprising that we are getting more reports," he said.
2020-10-25 10:29:21.0
Do you play any instruments? <a href="http://zobbing.co.uk/cost-of-celebrex-at-walmart">celebrex 200 mg kaufen</a> Barnes chose droll reminiscence to highlight the absurdity of the literary prize fandango but there have been less civilised reactions, with swearing, feuding and tantrums among publishers and authors.
2020-10-25 10:29:21.0
I sing in a choir <a href="http://www.mitoloji.org/zydena-vs-viagra.html">zydena 100mg udenafila</a> If a man walked up to a woman on the street and exposed himself, he would be arrested
2020-10-25 10:29:20.0
Canada>Canada <a href="http://zhidan.org/imipramine-half-life">imipramine drug uses</a> consumers spent $18.8 billion on bottled water last year, more than any other nation, according to Euromonitor International
2020-10-25 10:29:20.0
Can I take your number? <a href="http://zobbing.co.uk/cost-of-celebrex-at-walmart">celebrex joint pain</a> Under the proposed deal, Repsol will pay $8.3 billion incash for Talisman shares, a 56 percent premium to theCalgary-based company's market value of $5.33 billion on Monday.Repsol will also take on $4.7 billion of debt.