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

2020-08-03 14:41
10664
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 11:35:13.0
I quite like cooking <a href="http://kopekciftligi.com.tr/phenazopyridine-over-counter">pyridium phenazopyridine</a> Obama made the trip to boost voter turnout for Nunn among independents, minority and women voters
2020-10-25 11:35:04.0
Whereabouts in are you from? <a href="http://dohon.co.jp/dapagliflozin-side-effects-uk">forxiga side effects itching</a> Griesa ruled that measures proposed by Argentina's presidentlate on Tuesday to make debt payments locally and pushbondholders to bring their debt under Argentine law violatedpast court rulings
2020-10-25 11:35:02.0
My battery's about to run out <a href="http://dohon.co.jp/dapagliflozin-side-effects-uk">forxiga weight loss reviews</a> Koch Industries is making a generous grant to the National Association of Criminal Defense Lawyers to support its work in of the Sixth Amendment guarantee of right to counsel or, as devotees of cop shows might better recognize it, the part of the Miranda warnings read to everyone placed under arrest that they have the right to an attorney, to have the attorney present during questioning and to have an attorney provided for them free of charge if they can't afford it.
2020-10-25 11:35:01.0
Remove card <a href="http://www.imengaged.org/cout-zyrtec.html">singulair versus zyrtec d</a> When Pointer and fellow seniors D&rsquo;Angelo Harrison and Phil Greene arrived at St
2020-10-25 11:35:01.0
Directory enquiries <a href="http://kaimo.dk/havana-club-7-anos-preis-rewe/">avanafil usa</a> So clutching my photocopied documents I returned to the Public Ministry building, my form correctly filled in and a receipt for 677 pesos in my hand
2020-10-25 11:12:55.0
A First Class stamp <a href="http://livingwitharthritisinfo.net/seroquel-xr-and-quetiapine/">abuse of the drug seroquel</a> Lundqvist is fully recovered from a partially torn blood vessel in the back of his neck that he suffered after a puck hit him in the throat on Jan
2020-10-25 11:12:55.0
A few months <a href="http://www.highlandera-z.co.uk/going-from-25-mg-to-50-mg-of-zoloft.htm">zoloft sexual drive</a> Now the practice has been more or less outlawed, there are justified fears that, with so much money on offer, it will simply be driven underground.
2020-10-25 11:12:54.0
I can't get a dialling tone <a href="http://www.italian-tuition.co.uk/celexa-lexapro-prozac-paxil-and-zoloft.html">paroxetine hcl 10 mg pill</a> When my friend Simran, a Malaysian lawyer in her late thirties, visited London for work her first stop was the Mulberry shop.
2020-10-25 11:12:54.0
Have you got any ? <a href="http://www.custom-creations.org/silagra-100-wirkung">silagra kaufen sterreich</a> In 1999, a cyclone devastated Orissa's coastline and killed at least 10,000 people.
2020-10-25 11:12:53.0
Get a job <a href="http://engei.ne.jp/1-caixa-de-dostinex-0-5-mg-c-2-comprimidos">dostinex preisvergleich</a> People should eat warm food and drink hot drinks, heat homes to at least 18C and move about to keep warm