0

MySQL version: 5.6.25 (64-bit Linux). Ant version: 1.9.5. Sonarqube version: 5.1.1. I'm getting permission issues when I run my ant script. Things like:

org.sonar.runner.impl.RunnerException: Unable to execute Sonar ... .. caused by java.lang.IllegalStateException: Fail to connect to database .... ... caused by org.apache.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (access denied for user 'sonarqube'@'localhost' (using password: YES))

After spending yesterday afternoon of googling and trying to log into MySQL as root and calling GRANT ALL on etc etc for my sonarqube user and things like that I'm completely at a loss what to try next. I came across this post: http://sonarqube.15.x6.nabble.com/com-mysql-jdbc-Driver-is-not-found-td5012081.html, specifically this bit:

"Sonar uses its build-in driver which lies in /home/jenkins/sonar-3.5.1/extensions/jdbc-driver/mysql/ The file mysql-connector-java-5.1.18.jar exists, is readable and contains the Driver.class file."

I do not have a connector jar file in this location (in fact the only folder I have in the extensions directory is 'oracle'). Should I have one? In terms of the sonarqube documentation I don't have to configure MySQL to use anything extra drivers from elsewhere.

Many thanks in advance. I could paste in parts of my Ant script if required, but this does look more like a database permissions issue. Cheers, Tom

mutexe
  • 1
  • 1
  • edit: I've just noticed under the "Failed to connect to database" in the exception stack trace this:"at org.sonar.core.persistence.DefaultDatabase.start(DefaultDatabase.java:77)". Could this mean it's still trying to use some parts of the default H2 DB? I've removed all references of this from my sonar.properties file so now I'm even more confused :) – mutexe Jun 30 '15 at 09:15
  • you can try after export like export "ANT_LIB=/path-till-ant/apache-ant-1.9.4/lib" – Zafar Malik Jun 30 '15 at 09:17
  • Thanks for the reply. I have already set up an environmental variable for ant. Thank you though :) – mutexe Jun 30 '15 at 09:25

2 Answers2

0

Configure your MySQL, by default only localhost connection is enable.

GRANT ALL PRIVILEGES ON *.* TO 'user'@'YOUR_IP_ADDRESS'
Wender
  • 991
  • 15
  • 24
  • Thanks for the reply, but as I've said I've tried the 'grant all' commands for my (only) user. I did a "show grants" which confirms that my user has all privs on the db on localhost (which is where my db is). I also ran "select user, host, Grant_priv, Super_priv from mysql.user;" which came back with a "Y" in both privilege columns. So from a mysql point of view my user has privileges, but my sonar is giving me "(access denied for user 'sonarqube'@'localhost' (using password: YES))" messages. I am very confused :) – mutexe Jun 30 '15 at 15:23
0

First Thing first.

You are triggering SonarQube using ANT. For further details you can have a look here.

So, As per the Error log, it seems that its permission issue for your project. Sonar is unable to connect to your Database.

Suppose your database is Sonar

username = sonar
password = sonar

In this case you have to give privileges to your database for connecting. For providing privileges you have to run following commands.

GRANT ALL ON sonar.* TO 'sonar'@'localhost' IDENTIFIED BY 'sonar';
GRANT ALL ON sonar.* TO 'sonar'@'DOMAIN-NAME' IDENTIFIED BY 'sonar';
GRANT ALL ON sonar.* TO 'sonar'@'127.0.0.1' IDENTIFIED BY 'sonar';
GRANT ALL ON sonar.* TO 'sonar'@'CURRENT-IP-ADDRESS' IDENTIFIED BY 'sonar';

Please check for more details here.

Community
  • 1
  • 1
Abhijeet Kamble
  • 3,131
  • 2
  • 30
  • 36
  • Thanks for the reply. That first link was the exact website I used to modify my ant script, and as I said, I have tried all of the "GRANT ALL" command I'm afraid. Thanks again though. – mutexe Jul 03 '15 at 08:00
  • Login to mysql and type command select * from mysql.user and if possible comment the output. – Abhijeet Kamble Jul 03 '15 at 15:57