Glassfish將JDBC池從localhost更改為127.0.0.1 [重復]

[英]Glassfish change JDBC Pool from localhost to 127.0.0.1 [duplicate]


This question already has an answer here:

這個問題在這里已有答案:

This is my JDBC Connection Pool configuration:

這是我的JDBC連接池配置:

<jdbc-connection-pool max-pool-size="300" steady-pool-size="3" datasource-classname="com.mysql.jdbc.jdbc2.optional.MysqlDataSource" name="teDS" wrap-jdbc-objects="false" connection-validation-method="auto-commit" res-type="javax.sql.DataSource">
  <property name="URL" value="jdbc:mysql://localhost:3306/db"></property>
  <property name="port" value="3306"></property>
  <property name="DatabaseName" value="db"></property>
  <property name="serverName" value="localhost"></property>
  <property name="password" value="XXX"></property>
  <property name="url" value="jdbc:mysql://localhost:3306/db"></property>
  <property name="user" value="user"></property>
</jdbc-connection-pool>

PLEASE HELP ME

請幫我

But I PING connection have this error:

但我PING連接有這個錯誤:

An error has occurred Ping Connection Pool failed for teDS. Connection could not be allocated because: Access denied for user 'user'@'127.0.0.1' (using password: YES) Please check the server.log for more details.

發生錯誤Ping連接池因teDS而失敗。無法分配連接,因為:用戶'user'@'127.0.0.1'拒絕訪問(使用密碼:是)請查看server.log以獲取更多詳細信息。

Ping ERROR

1 个解决方案

#1


1  

A user in MySQL is identified by a username AND a host.

MySQL中的用戶由用戶名和主機標識。

To allow a connection, we need to create a user in MySQL that has a matching username and host. To create a user that is an exact match:

為了允許連接,我們需要在MySQL中創建一個具有匹配用戶名和主機的用戶。要創建完全匹配的用戶:

 GRANT USAGE ON *.* TO 'user'@'127.0.0.1' IDENTIFIED BY 'supersecretpassword' ;
 GRANT SELECT, INSERT, UPDATE, DELETE ON somedatabase.* TO 'user'@'127.0.0.1' ;

To replicate the privileges of an existing user, we could make use of a SHOW GRANTS statement to extract privileges for some other user

要復制現有用戶的權限,我們可以使用SHOW GRANTS語句為其他用戶提取權限

 SHOW GRANTS FOR 'user'@'localhost'

We can copy the output from that, and use that as a basis for GRANT statements for the new user, replacing 'localhost' with '127.0.0.1'.

我們可以復制該輸出,並將其用作新用戶的GRANT語句的基礎,將'localhost'替換為'127.0.0.1'。

As another option, it's also possible to create a user with a '%' wildcard for a hostname, rather than '127.0.0.1'. That would allow connections from any IP address.

作為另一種選擇,還可以為主機名創建具有'%'通配符的用戶,而不是'127.0.0.1'。這將允許來自任何IP地址的連接。


If the user exists, then the password could be wrong. Verify that the password the pool configuration is using matches what is stored in the mysql.user table.

如果用戶存在,則密碼可能是錯誤的。驗證池配置使用的密碼是否與mysql.user表中存儲的密碼相匹配。

SELECT password FROM mysql.user WHERE user = 'user' and host = '127.0.0.1';

SELECT PASSWORD('supersecretpassword') ;

And compare the hash values.

並比較哈希值。

The error message that is being returned looks like it is from MySQL server:

正在返回的錯誤消息看起來像是來自MySQL服務器:

Access denied for user 'user'@'127.0.0.1' (using password: YES)

用戶'user'@'127.0.0.1'拒絕訪問(使用密碼:是)

That makes is appear that a successful TCP handshake through port 3306 has happened, and MySQL Server is attempting to authenticate: user='user', host='127.0.0.1', and password=PASSWORD('XXX').

這表明通過端口3306發生了成功的TCP握手,並且MySQL服務器正在嘗試進行身份驗證:user ='user',host ='127.0.0.1',password = PASSWORD('XXX')。

Either the user doesn't exist in the mysql.user table, the password is incorrect, or (possibly) the user doesn't have privileges on database='db'.

用戶不存在於mysql.user表中,密碼不正確,或者(可能)用戶沒有database ='db'的權限。

(If DML changes were applied to the privileges table in the mysql database, issue a FLUSH PRIVILEGES to make those changes effective. (FLUSH PRIVILEGES isn't required if changes are applied using GRANT and REVOKE syntax, only required if changes are applied using INSERT, UPDATE, DELETE.)

(如果將DML更改應用於mysql數據庫中的特權表,則發出FLUSH特權以使這些更改生效。(如果使用GRANT和REVOKE語法應用更改,則不需要FLUSH PRIVILEGES,僅在使用INSERT應用更改時才需要FLUSH PRIVILEGES ,更新,刪除。)


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2017/03/01/72a2668cc1c5998ed40b39f9d4dfcb8a.html



 
粤ICP备14056181号  © 2014-2020 ITdaan.com