Access denied for user '=root'@'localhost' (using password: YES)解决方案&&修改mysql默认引擎

问题一

问题描述:Caused by: java.sql.SQLException: Access denied for user ‘=root’@’localhost’ (using password: YES)
在连接数据库时,用户名和密码不正确,网上的方法多是让我修改连接数据库密码,但我将密码从123456改为111111.问题还未能解决,仔细看了xml中配置数据源的代码后!呵呵!多写了两个“=”!!!瞬间崩溃!!!
Access denied for user '=root'@'localhost' (using password: YES)解决方案&&修改mysql默认引擎_第1张图片
就是这两个等号~
我找了一晚上~
呵呵 ~
因此~网上说的让你更改数据库密码还是正确的~

问题二

问题描述:xml配置文件中写了让事务回滚,但在往数据库添加的时候,日志文件已提示事务回滚,但仍然将数据插入数据库中。

    
    <tx:advice id="txAdvice" transaction-manager="transactionManager">
        <tx:attributes>
            <tx:method name="get*" read-only="true"/>
          <tx:method name="*" rollback-for="exception">tx:method>
        tx:attributes>
    tx:advice>

    
    <aop:config>
        <aop:pointcut id="allMethod" expression="execution(* com.neusoft.dao.*.*(..))"/>
        <aop:advisor advice-ref="txAdvice" pointcut-ref="allMethod"/>
    aop:config>

这里写图片描述

解决方案:将mysql自动提交关闭,方法为:修改引擎为InnoDB。
步骤:
1.打开mysql数据库,执行:show engines;查看引擎
Access denied for user '=root'@'localhost' (using password: YES)解决方案&&修改mysql默认引擎_第2张图片
可以看到InnoDB中的support属性为yes,默认的引擎为MyISAM。
2.应该将默认的引擎更改为InnoDB,更改方法:

  • 打开MySQL安装目录底下的my.ini文件
  • 将:default-storage-engine=InnoDB 增加至文件末尾,保存,关闭
  • 重启mysql(一定要记得重启)会发现:
    Access denied for user '=root'@'localhost' (using password: YES)解决方案&&修改mysql默认引擎_第3张图片

这时就把引擎更改为InnoDB,mysql就不会自动提交了

你可能感兴趣的:(框架学习,项目)