Caused by: java.sql.SQLException: Access denied for user 'dell-pc'@'xxxxx' (using password: YES)
今天遇到一個非常坑的異常。
在做SSM專案整合的時候,遇到了上面這個異常,我一看連線資料庫的username
怎麼變成了 dell-pc
,然而jdbc.properties
:
username=root
password=123456
spring配置為:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<context:property-placeholder location="classpath:jdbc.properties"/>
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="${driver}"/>
<property name="jdbcUrl" value="${url}"/>
<property name="user" value="${username}"/>
<property name="password" value="${password}"/>
<property name="maxPoolSize" value="30"/>
<property name="minPoolSize" value="10"/>
<property name="autoCommitOnClose" value="false"/>
<property name="checkoutTimeout" value="0"/>
<property name="acquireRetryAttempts" value="2"/>
</bean>
其中<property name="user" value="${username}"/>
在設定的時候也能自動顯示username的值為root,一直報異常真頭疼。
後來我發現了兩種解決方案
第一種:直接把username通通改成name
第二種:<context:property-placeholder location="classpath:jdbc.properties"/>
後新增屬性system-properties-mode=”FALLBACK”:<context:property-placeholder location="classpath:jdbc.properties" system-properties-mode="FALLBACK"/>
系統預設為system-properties-mode=”ENVIRONMENT” 意思就是從系統環境中去讀取,把電腦名當做mysql的使用者名稱,修改之後,執行成功。
相關文章
- java.sql.SQLException: Access denied for user ‘root‘@‘localhost‘ (using password: YES)JavaSQLExceptionlocalhost
- ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password:YES)Errorlocalhost
- 啟動報錯:Access denied for user 'root'@'localhost' (using password:YES)localhost
- Linux錯誤 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)LinuxErrorlocalhost
- SpringBoot中yml配置java.sql.SQLException: Access denied for user ‘root‘@‘localhost‘ (using password: NOSpring BootJavaSQLExceptionlocalhost
- mysql 1045, "Access denied for user 'root'@'localhost' (using password: NO)"MySqllocalhost
- Navicat遠端連線MySQL 提示1045 - Access denied for user 'root'@'223.74.158.192'(using password:YES)MySql
- MySQL系列:Docker安裝 MySQL提示錯誤:Access denied for user'root'@'localhost' (using password:yes)MySqlDockerlocalhost
- vue專案中連線MySQL時,報錯ER_ACCESS_DENIED_ERROR: Access denied for user 'root'@'localhost' (using password:YES)VueMySqlErrorlocalhost
- mac os x 安裝mysql遇到 Access denied for user ‘root‘@‘localhost‘ (using password: YES)的解決方法MacMySqllocalhost
- 報錯”ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: NO)”Errorlocalhost
- SQLSTATE[HY000] [1045] Access denied for user ‘root‘@‘localhost‘ (using password: YES)”錯誤的隱藏解決辦法SQLlocalhost
- 解決Mysql:ERROR 1045 (28000):Access denied for user ‘root‘@‘localhost‘ (using password: NO)的方法MySqlErrorlocalhost
- MySQL 8.0.13 密碼問題 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)MySql密碼Errorlocalhost
- ubuntu mysql Access denied for user root@localhostUbuntuMySqllocalhost
- Permission denied:user=xxx,access=WRITE,inode=xxx
- Access denied for user 'default'@'%' to database 'shop'報錯Database
- Access denied for user ‘root‘@‘localhost‘問題的解決localhost
- Ubuntu18.04:mysql:ERROR 1698 (28000): Access denied for user ‘root‘@‘localhost‘UbuntuMySqlErrorlocalhost
- MySQL:You must reset your password using ALTER USER statement before executing this statement.MySql
- hive建立分割槽表報錯AccessControlException Permission denied: user=NONE, access=WRITE, inodeHiveExceptionNone
- MySQL使用普通使用者訪問返回ERROR 1698 (28000): Access denied for user 'root'@'localhost'MySqlErrorlocalhost
- 【本人親測 已解決】044 - Access denied for user ‘root‘@‘%‘ to database ‘資料庫名稱‘Database資料庫
- nginx中報Access denied.Nginx
- OGG Director連線報錯Access denied
- laravel mysql批量提交報Access denied 錯誤LaravelMySql
- Caused by: java.sql.SQLException: 無法從套接字讀取更多的資料JavaSQLException
- sqlplus / as sysdba報錯ORA-01017: invalid username/password; logon deniedSQLGo
- 【YashanDB資料庫】YAS-02143 invalid username/password, login denied資料庫
- 消除Warning: Using a password on the command line interface can be insecure的提示
- 504.3 Password and Access Attacks 密碼和訪問攻擊密碼
- [20201120]pam_systemd(crondsession) Failed to create session Access denied.txtSessionAI
- 網站程式呼叫資料庫時提示“command denied to user”網站資料庫
- Windows git remote: HTTP Basic: Access denied 錯誤解決辦法WindowsGitREMHTTP
- NFS掛載時出現”access denied by server while mounting”的解決方法NFSServerWhile
- undefine macro xxxxxMac
- Edge崩潰(Edge錯誤程式碼STATUS_ACCESS_DENIED的修復方法)
- 安裝kernel...src.rpm錯誤:warning: user mockbuild does not exist - using rootMockUI