无法在詹金斯上创建 PoolableConnectionFactory

Cannot create PoolableConnectionFactory on jenkins

我在 MySql 中使用 Sonarqube。我有 Jenkins,我想将 Sonar runner 与 TC 集成,主要用于不同的项目(Java、PHP)。我做了以下工作:

  1. 在 windows 平台中下载 sonar zip(最新版本)。
  2. StartSonar.bat
  3. 我在远程虚拟机的 CentOS 中有一个 MySQL:
    • 我使用 Cygwin ssh 连接到远程 MySQL:
    • 然后我创建一个架构,如下所示:

MySQL:

CREATE DATABASE sonar CHARACTER SET UTF8;
CREATE USER 'sonar'@'*' IDENTIFIED BY 'sonar';
GRANT ALL ON sonar.* TO 'sonar'@'*';
FLUSH PRIVILEGES;
  1. 然后我禁用了 VM 防火墙:sudo systemctl stop firewalld
  2. 当我使用 StartSonar.bat 启动声纳时,出现以下错误:

堆栈跟踪:

Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user 'sonar'@'10.1.162.61' (using password: YES))
    at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1549) ~[commons-dbcp-1.4.jar:1.4]
    at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388) ~[commons-dbcp-1.4.jar:1.4]
    at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044) ~[commons-dbcp-1.4.jar:1.4]
    at org.sonar.core.persistence.DefaultDatabase.checkConnection(DefaultDatabase.java:115) ~[sonar-core-5.1.2.jar:na]
    ... 28 common frames omitted

Caused by: java.sql.SQLException: Access denied for user 'sonar'@'10.1.162.61' (using password: YES)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:996) ~[mysql-connector-java-5.1.34.jar:5.1.34]

请问我在这里遗漏了什么?

解决方案是在 conf 文件夹的 sonar.properties 中启用声纳凭证,如下所示:

# User credentials.
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar

#----- MySQL 5.x
# Only InnoDB storage engine is supported (not myISAM).
# Only the bundled driver is supported.
sonar.jdbc.url=jdbc:mysql://10.1.163.103:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance