• mybatis或hibernate框架连接数据库报错:java.sql.SQLException: Access denied for user 'Administrator'@'localhost' (using password: YES)


    报错信息:

    java.sql.SQLException: Access denied for user 'Administrator'@'localhost' (using password: YES)

    严重: create connection SQLException, url: jdbc:mysql://localhost:3306/db2?&useSSL=false&serverTimezone=UTC, errorCode 1045, state 28000
    java.sql.SQLException: Access denied for user 'Administrator'@'localhost' (using password: YES)
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
        at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
        at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:835)
        at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:455)
        at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:240)
        at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:199)
        at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1644)
        at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1710)
        at com.alibaba.druid.pool.DruidDataSource$CreateConnectionThread.run(DruidDataSource.java:2753)

    明明密码对的,被拒绝了,找了好久原因,后来发现将db.properties配置文件里的username改为jdbc.username就好了,可能是因为username被系统变量占用了。
    当spring容器在进行启动的时候,会读取当前系统某些环境变量的配置,当前系统的用户名使用username来表示的,所以做好的方式是添加前缀,使用jdbc.username.

    jdbc.username=root
    jdbc.password=root
    jdbc.url=jdbc:mysql://localhost:3306/db2?&useSSL=false&serverTimezone=UTC
    jdbc.driverClassName=com.mysql.cj.jdbc.Driver

    转: https://www.cnblogs.com/tyhA-nobody/p/13166892.html

  • 相关阅读:
    Python [Leetcode 350]Intersection of Two Arrays II
    jade学习
    pageX、clientX、screenX、offsetX、layerX、x
    AngularJS--转载
    AngularJS
    超级强大的SVG动画详解
    javascript event对象的clientX,offsetX,screenX,pageX区别
    console的调试方法
    javascript--函数参数与闭包--详解
    如何把你的图标转换成web字体
  • 原文地址:https://www.cnblogs.com/fps2tao/p/14109885.html
Copyright © 2020-2023  润新知