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

2020-08-03 14:41
10674
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 09:22:10.0
Do you play any instruments? <a href="http://alternativemedicinesreview.com/can-i-buy-oxybutynin-over-the-counter.html">oxytrol patch otc reviews</a> Imagining some snow falling on Vegas, I had this huge welter of images and I thought it was going to be a sort of bizarre descriptive song but in fact it became a metaphor for the seemingly impossible.&#8221;
2020-10-25 09:22:09.0
Is this a temporary or permanent position? <a href="http://weightloss-basics.com/ranitidine-omeprazole-baby">prilosec sprint car</a> The remarks generated negativeheadlines and widespread criticism on social media.
2020-10-25 09:22:08.0
I'd like to send this parcel to <a href="http://www.londonconnects.org.uk/prix-teva-olanzapine.cfm">zyprexa and clozaril</a> The people tasked with arresting him have been given clear orders from President Juan Manuel Santos and Defence Minister Juan Carlos Pinzon: Do not leave Uraba until you have caught Otoniel and have dismantled the whole clan.
2020-10-25 09:22:08.0
Just over two years <a href="http://www.londonconnects.org.uk/prix-teva-olanzapine.cfm">olanzapine dose ocd</a> Bristol-Myers Squibb Co is expected to report lower fourth-quarter sales and earnings, amidfalling sales of its treatments for HIV and the loss of diabetes drugs that it sold off earlierin the year to AstraZeneca Plc
2020-10-25 09:22:06.0
Very Good Site <a href="http://www.londonconnects.org.uk/chloroquine-webmd.cfm">chloroquine resistance tanzania</a> Bergdahl's release in May was initially greeted by euphoria, given he had spent five years as a Taliban captive after walking away from his outpost in Afghanistan
2020-10-25 09:00:05.0
Will I get paid for overtime? <a href="http://kbtlund.se/acheter-propranolol-sans-ordonnance">propranolol heart palpatations hand tremors</a> However, this is a myth, the researchers insisted, and in fact, people who smoke tend to crave more fatty foods than non-smokers.
2020-10-25 09:00:04.0
Enter your PIN <a href="http://prepa-sarcelles.fr/amiodarone-tablet-dosage.php">amiodarone 200 mg side effects</a> They looked at 31 cancer types and found that 22 of them,including leukemia and pancreatic, bone, testicular, ovarian andbrain cancer, could be explained largely by these randommutations - essentially biological bad luck.
2020-10-25 09:00:03.0
Could you transfer $1000 from my current account to my deposit account? <a href="http://theformationquest.org/digoxin-furosemide.htm">digoxin and solubility</a> After increasing capital spending by 6 percent in thejust-completed fiscal year, small manufacturers plan a 14percent decrease in the current year, according to the Bank ofJapan's quarterly survey released this week
2020-10-25 09:00:03.0
Could you tell me the number for ? <a href="http://vaccineresource.com/buy-depo-provera-online-uk/">comprar provera en espaa</a> He completed 56.3% of those deep throws, prompting questions about how he&rsquo;ll perform in a conventional pro-style offense
2020-10-25 09:00:02.0
Could I have a statement, please? <a href="http://vaccineresource.com/rogaine-hair-products-reviews/">rogaine foam bad</a> The Bank of Japan is widely expected to keep monetary settings unchanged at its two-day policy meeting ending on Tuesday, but it is likely to offer a bleaker view on industrial production, reflecting a surprise plunge in August's factory output.