mysql的声纳配置失败

时间:2012-09-24 20:28:25

标签: php mysql continuous-integration jenkins sonarqube

我试图第一次对我们的回购运行声纳 - 跑步者......

我有:

  1. 安装Sonar 3.2并安装在/ opt / sonar
  2. 在/opt/sonar-runner-2.0 /
  3. 中安装并配置了声纳运行器
  4. 安装PHP扩展插件并放入/opt/sonar/extensions/plugins/sonar-php-plugin-1.1.jar
  5. 我的sonar.properties文件具有以下属性:

       sonar.jdbc.username:                       sonar
       sonar.jdbc.password:                       sonar
       sonar.jdbc.url:                            jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true
       sonar.jdbc.driverClassName:                com.mysql.jdbc.Driver
    

    虽然用户/密码设置为声纳/声纳,但声纳 - 跑步者仍在尝试以root @ localhost身份连接...请参阅下面的跟踪:

    Caused by: java.lang.IllegalStateException: Fail to connect to database
        at org.sonar.core.persistence.DefaultDatabase.start(DefaultDatabase.java:66)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:616)
        at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.invokeMethod(ReflectionLifecycleStrategy.java:110)
        ... 20 more
    Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user 'root'@'localhost' (using password: YES))
        at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1549)
        at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388)
        at org.apache.commons.dbcp.BasicDataSource.getLogWriter(BasicDataSource.java:1098)
        at org.apache.commons.dbcp.BasicDataSourceFactory.createDataSource(BasicDataSourceFactory.java:350)
        at org.sonar.core.persistence.DefaultDatabase.initDatasource(DefaultDatabase.java:117)
        at org.sonar.core.persistence.DefaultDatabase.start(DefaultDatabase.java:62)
        ... 25 more
    Caused by: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3609)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3541)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:943)
        at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:4113)
        at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1308)
        at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2336)
        at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2369)
        at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2153)
        at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:792)
        at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
        at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:381)
        at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)
        at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)
        at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:582)
        at org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1556)
        at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1545)
        ... 30 more
    

    我在更改配置后重新启动了声纳服务器...

    是否可以使用空/空密码?如果我注释掉sonar.jdbc.password,那么声纳GUI将抛出500状态代码。如果我将sonar.jdbc.password留空/空白,则它仍会尝试使用密码连接:'root'@'localhost' (using password: YES) !!

    非常感谢

1 个答案:

答案 0 :(得分:3)

stacktrace详细说明错误:

Caused by: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)

看起来配置不符合您的错误。您是否尝试过配置Sonar以使用root用户?

我怀疑你的问题与mySQL用户访问有关。您是否尝试以“声纳”用户身份连接数据库?

更新

Sonar runner不使用与Sonar服务器相同的配置文件。在以下位置查找文件:

$SONAR_RUNNER_HOME/conf/sonar-runner.properties