美文网首页
MAC MyBatis访问MySQL 8 报错consider

MAC MyBatis访问MySQL 8 报错consider

作者: lczalh | 来源:发表于2019-12-03 09:36 被阅读0次

    原因是:安装MySQL 8过程中的Authentication Method这一配置过程,基于不同的加密方式。

    // 登录MySQL
    mysql -u root -p
    // 更改加密方式 (666666为mMySQL密码)
    ALTER USER 'root'@'localhost' IDENTIFIED BY '666666' PASSWORD EXPIRE NEVER;
    // 更改密码
    ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '666666';
    // 重启MySQL
    mysql.server restart
    

    2.常见问题

    2.1 MySQL 8 driver为:com.mysql.cj.jdbc.Driver

    Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and
    manual loading of the driver class is generally unnecessary.
    

    2.2 url中没有设置useSSL=false

    WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements <br>SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate<br> property is set to 'false'.You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate<br> verification.
    

    2.3 url中没有设置serverTimezone=UTC

    The server time zone value '???ú±ê×??±??' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the 
    serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
    

    2.4 url中参数没有用;拼接 & -> &

    The reference to entity “useSSL” must end with the ‘;’ delimiter.
    

    3. MySQL 8 连接配置

    <property name="driver" value="com.mysql.cj.jdbc.Driver"/> 
    <property name="url" value="jdbc:mysql://localhost:3306/mybatis?serverTimezone=UTC&amp;characterEncoding=utf8&amp;useUnicode=true&amp;useSSL=false"/>
    <property name="username" value="root"/>
    <property name="password" value="123456"/>
    

    相关文章

      网友评论

          本文标题:MAC MyBatis访问MySQL 8 报错consider

          本文链接:https://www.haomeiwen.com/subject/quaqgctx.html