在运行docker时,我得到了'java.sql.SQLNonTransientConnectionException:不允许公共(public)密钥检索'。我正在使用jhipster整体项目。并且我已经尝试过'allowPublicKeyRetrieval = true'解决方案。如果正在使用,则意味着又得到了一个更多错误,例如“用户'root'@'localhost'的访问被拒绝。请帮助我解决此错误。我从1周开始就遇到了同样的问题。
这是我的.yo-rc.json
{
"generator-jhipster": {
"promptValues": {
"packageName": "com.niche.ng",
"nativeLanguage": "en"
},
"jhipsterVersion": "6.5.0",
"applicationType": "monolith",
"baseName": "Nichehands",
"packageName": "com.niche.ng",
"packageFolder": "com/niche/ng",
"serverPort": "8080",
"authenticationType": "session",
"cacheProvider": "ehcache",
"enableHibernateCache": false,
"websocket": false,
"databaseType": "sql",
"devDatabaseType": "mysql",
"prodDatabaseType": "mysql",
"searchEngine": false,
"messageBroker": false,
"serviceDiscoveryType": false,
"buildTool": "maven",
"enableSwaggerCodegen": false,
"rememberMeKey": "b9f603400b9bd1cf887c6efbba0e8e3822cf735d083441758e81667adef95db8af19462970cfece6048f0be25cc",
"embeddableLaunchScript": false,
"useSass": true,
"clientPackageManager": "npm",
"clientFramework": "angularX",
"clientTheme": "none",
"clientThemeVariant": "",
"testFrameworks": [],
"jhiPrefix": "jhi",
"entitySuffix": "",
"dtoSuffix": "DTO",
"otherModules": [],
"enableTranslation": true,
"nativeLanguage": "en",
"languages": [
"en",
"hi",
"ta",
"te"
],
"blueprints": []
}
}
最佳答案
可能的原因:
可能的解决方案:
CREATE USER 'apppuser'@'localhost' IDENTIFIED BY 'topsecret';
CREATE USER 'apppuser'@'%' IDENTIFIED BY 'topsecret';
GRANT SELECT ON dbname.* to 'apppuser'@'localhost';
GRANT INSERT ON dbname.* to 'apppuser'@'localhost';
GRANT UPDATE ON dbname.* to 'apppuser'@'localhost';
GRANT DELETE ON dbname.* to 'apppuser'@'localhost';
GRANT SELECT ON dbname.* to 'apppuser'@'%';
GRANT INSERT ON dbname.* to 'apppuser'@'%';
GRANT UPDATE ON dbname.* to 'apppuser'@'%';
GRANT DELETE ON dbname.* to 'apppuser'@'%';
然后更改您的docker-compose凭证
DBUSER='apppuser'
DBPASSWORD='topsecret'
然后在您的docker-compose文件中将此变量添加为
${DBUSER} and ${DBPASSWORD}
。 /etc/environment
中添加环境属性。请记住,不能将属性与'#'一起使用,因为它将被视为注释。 请发送您的docker-compose文件和production.yml文件。