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

2020-08-03 14:41
10678
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 12:19:22.0
I'm a housewife <a href="http://www.ttr-codnor.co.uk/acheter-moduretic-en-ligne.html">para que serve moduretic 50 mg</a> First, we should discard the double standard that we&rsquo;ve long applied to Islam as compared to other religions.That means we should view Islam as an appropriate target for criticism and satire, as we do Christianity and Judaism
2020-10-25 12:19:21.0
Sorry, I'm busy at the moment <a href="http://asoupar.ir/?order-finasteride-online-uk">finasteride for hair loss side effects</a> Jason Chaffetz, R-Utah, John Conyers, D-Mich., and Peter Welch, D-Vt., with a Senate version from Sens
2020-10-25 12:19:21.0
Accountant supermarket manager <a href="http://www.ttr-codnor.co.uk/acheter-moduretic-en-ligne.html">moduretic prescription needed</a> &ldquo;I would look at all the food retailers and ask &ndash; is this retailer looking to drive footfall into their shop to maintain its vitality?&rdquo; he explains
2020-10-25 12:19:20.0
How many weeks' holiday a year are there? <a href="http://galopturk.com/?antabuse-alcohol-reaction-time">disulfiram reaction that occurs with metronidazole and alcohol</a> A serious point -- to improve voter turnout among the young, I feel, you need to start early
2020-10-25 12:19:20.0
My battery's about to run out <a href="http://www.ttr-codnor.co.uk/acheter-moduretic-en-ligne.html">bula moduretic 50</a> Accompanied by the mid-range 730, Nokia also launched a new wireless charging plate and screen0-sharing device called the HD-10 to allow Lumia users to project content on their phones to their TV screens.
2020-10-25 11:57:14.0
I'd like to change some money <a href="http://neec2010.co.uk/enalapril-side-effects-erectile-dysfunction.aspx">what is enalapril medication</a> Intel suggests that the Compute Stick be used for "light productivity, social networking, Web browsing, and streaming media or games." It also said small businesses might use it as an inexpensive computing solution.
2020-10-25 11:57:13.0
How would you like the money? <a href="http://plateroytu.com/metoclopramide-hcl-oral-tablet-10-mg">metoclopramide hydrochloride 10 mg tablets</a> &ldquo;I&rsquo;ve done well so far, and I&rsquo;m confident I&rsquo;ll reach my 24th birthday in January,&rdquo; she said
2020-10-25 11:57:12.0
I'm happy very good site <a href="http://neec2010.co.uk/enalapril-side-effects-erectile-dysfunction.aspx">vasotec children ae</a> Chip Kelly said the Eagles won't trade up to acquire Mariota in the draft and Sam Bradford looks to be his quarterback after a trade with St
2020-10-25 11:57:11.0
A law firm <a href="http://pasen.com.cn/inj-toradol-uses">toradol tbx</a> Their findings are altogether different from what was expected, the rate of the expansion of the universe is much slower than formerly thought.
2020-10-25 11:57:11.0
I'd like to send this parcel to <a href="http://www.ehsandiary.ir/harga-tablet-cefixime/">suprax dose pediatric uti</a> The Europa mission will really start coming into focus just a few months from now: NASA aims to select science instruments for the mission this spring, NASA Administrator Charles Bolden said Monday