1. 程式人生 > >mybatis connection error Cannot create PoolableConnectionFactory (Access denied for user 'root '@'local

mybatis connection error Cannot create PoolableConnectionFactory (Access denied for user 'root '@'local

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException:
Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException:
Cannot create PoolableConnectionFactory (Access denied for user 'root '@'localhost' (using password: YES))
### The error may exist in com/sample/mappers/EmployeeMapper.xml
### The error may involve com.sample.dao.EmployeeDao.listall
### The error occurred while executing a query
### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException:
Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException:
Cannot create PoolableConnectionFactory (Access denied for user 'root '@'localhost' (using password: YES))

notice: the user is 'root ' not 'root'

這個問題大致就是需要檢查你的資料來源配置即Resource中的:url,username,password

url這個一般是"jdbc:mysql://localhost:3306/test",一定要注意3306,這個是你資料庫連線用的埠,可以把它改成別的,但是如果你用的tomcat容器,別把它寫成8080,這樣就會產生Cannot create PoolableConnectionFactory (Communications link failure問題,還有就是url=jdbc:mysql://localhost:3306/test中的localhost,也不是隨便配置的,要看你的資料庫中的from host

我當時實在MySql Workbench5.2 CE中的 Users and Privileges中,有個Server Access Management

User  From Host 你看From Host中有沒有localhost,如果有你就能寫成url=jdbc:mysql://localhost:3306/test,要是from host有127.0.0.1的話,也可以寫成url=jdbc:mysql://127.0.0.1:3306/test

還有就是 username=  這個一定要寫正確,我當時寫的是name= ,結果mysql找不到username,然後他自動把username設為"",以至於錯誤提示: java.sql.SQLException: Access denied for user ‘’ 

@'localhost' (using password: YES) 你看到@前面是兩個單引號了嗎,那就是我沒輸入username而導致預設的預設username,其實這個錯誤也可以用設定許可權改,但是那是mysql內容,就不說了。

總結起來就是:url埠要寫對,不能寫其他程式被佔用的,127.0.01還是localhost要看資料庫裡面有哪個,還要就是把對的驅動放入專案中的WEB-INF/lib裡,這裡提一下不用再放到tomcat的lib中。

相關推薦

mybatis connection error Cannot create PoolableConnectionFactory (Access denied for user 'root '@'local

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause:

Cannot create PoolableConnectionFactory (Access denied for user ''@'localhost' (using password: YES)

Cannot create PoolableConnectionFactory (Access denied for user ‘’@‘localhost’ (using password: YES))在使用dbcp連線池獲取資料庫連線時出現的異常解決方法 按照

SSM整合問題:Cannot create PoolableConnectionFactory (Access denied for user 'Administrator'@'localhost'

**org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: ### Error quer

ERROR 1045 (28000): Access denied for userroot‘@

align 情況 找到 pda pri 依然 left fail tex ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using passwor 錯誤描述

Error:1045, "Access denied for user 'root'@'localhost' (using password: YES) (Phon3.6+Mysql8.1 )

哇,鬧了一個大烏龍,昨天,寫了個指令碼給之前移植的mysql新增資料,結果一個小問題困了我0.75天。 指令碼程式碼如下:(期間有個小插曲,我把port=“3306”,報錯了,但是很快排查到,去除可雙引號) from pymysql import cursors, connect #

解決MySQL登入ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using passwor)問題

問題描述 今天在MAC上安裝完MYSQL後,MYSQL預設給分配了一個預設密碼,但當自己在終端上使用預設密碼登入的時候,總會提示一個授權失敗的錯誤:Access denied for user ‘root’@’localhost’ (using passwor)如圖

mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'root'@'localhost

ubutun裝mysql,步驟: sudo apt-get install mysql-server sudo apt isntall mysql-client sudo apt install libmysqlclient-dev 安裝成功後可以通過下面的命

MYSQL重置密碼 MySQL ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password:YES)

一般這個錯誤是由密碼錯誤引起,解決的辦法自然就是重置密碼。 假設我們使用的是root賬戶。 1.重置密碼的第一步就是跳過MySQL的密碼認證過程,方法如下: #vim /etc/my.cnf(注:windows下修改的是my.ini) 在文件內搜尋mysqld定位

Ubuntu server裡登入mySql時報錯:Mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost'的纖細解決方案

問題如下: 輸入正確密碼後,卻出現錯誤 首先我們用vi編輯器進入mysql的配置檔案mysqld.cnf 我們在檔案裡內容找到mysqld這一目錄,在其目錄下新增一行skip-grant-tables 隨後按esc鍵輸入:wq儲存退出 退出後

Linux錯誤 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: YES) 翻譯: 錯誤1045(28000):對使用者“root”@本地主機拒絕訪問(使用密碼:是) 一

ubuntu 16.04安裝mysql5.7.17後,登入時出現ERROR 1045 (28000): Access denied for user 'root'@'localhost' 問題解決!

一、問題描述     今天,筆者為了練習sql,在ubuntu16.04上安裝了mysql。筆者在網上搜索了在ubuntu16.04安裝mysql的步驟,並跟著步驟一步步操作,然而,讓筆者無法明白的是,網上說在安裝mysql的過程會彈出輸入密碼的視窗,然而筆者在安裝的過程中

centos7 上安裝mysql5.7後登入報錯ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using pas

安裝完mysql後會有個臨時密碼去日誌檢視,但是檢視登入修改密後還是不行 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password:yes) 於是 1,停止mysql服務 sy

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)問題的解決辦法

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)該故障碼的意思是拒絕訪問資料庫。 一般出現該故障碼是由於資料庫的賬號或密碼被更改過所致。解決的辦法是更改資

Spring mybatis Access denied for user 'root'@'localhost' (using password:YES)

    spring 3.X 提供了  <context:property-placeholderlocation="classpath:prop/jdbc.properties" /> 方便載入資料庫配置。 今天我用spring4.X 和 dbcp2 整合

Nodejs Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'root'@'xx' (using password:YES)

原程式: var mysql = require('mysql'); var connection = mysql.createConnection({ host : 'xxx

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

http://blog.csdn.net/qq160816/article/details/7722680 錯誤描述: Mysql中新增使用者之後可能出現登入時提示ERROR 1045 (28000): Access denied for user的錯誤.刪除user

【mysql】linux用yum安裝mysql後,登陸root使用者提示ERROR 1045 (28000): Access denied for user 'root'@'localhost' (..

系統是CentOS 6.8 yum -y install mysql mysql-server mysql-devel 安裝完之後 [root@iZwz9gjh3pbz2k2hin7cg8Z ~]# mysql -uroot -p 報

遇到問題---mysql賬戶密碼以及許可權的問題 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using passwor

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using passwor 這種型別的提示是帳號密碼不對或者帳號不存在的現象。 我們先來梳理一下mysql的賬戶密碼思路  mysql安裝完後 ro

MySQL ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)的真正原因

[[email protected] tmp]# rpm -ivh MySQL-server-advanced-5.6.20-1.rhel5.x86_64.rpmPreparing...                #########################################

Linux mysql 5.6: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

tail -200 /var/lib/mysql/DB-Server.err | more2014-07-22 14:59:41 9346 [Note] Shutting down plugin 'binlog'2014-07-22 14:59:41 9346 [Note] /usr/sbin/mysqld: