Kuldeep Darmwal
Kuldeep Darmwal

Reputation: 185

in sonarqube- SELECT command denied to user 'sonar_user'@'localhost' for table 'session_variables

Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (SELECT command denied to user 'sonar_user'@'localhost' for table 'session_variables') 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:113) ~[sonar-core-4.5.5.jar:na] ... 27 common frames omitted Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: SELECT command denied to user 'sonar_user'@'localhost' for table 'session_variables' at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_60] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_60] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_60] at java.lang.reflect.Constructor.newInstance(Constructor.java:422) ~[na:1.8.0_60] at com.mysql.jdbc.Util.handleNewInstance(Util.java:411) ~[mysql-connector-java-5.1.27.jar:na] at com.mysql.jdbc.Util.getInstance(Util.java:386) ~[mysql-connector-java-5.1.27.jar:na] at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054) ~[mysql-connector-java-5.1.27.jar:na] at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4237) ~[mysql-connector-java-5.1.27.jar:na] at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4169) ~[mysql-connector-java-5.1.27.jar:na] at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2617) ~[mysql-connector-java-5.1.27.jar:na]

Upvotes: 1

Views: 697

Answers (2)

Kuldeep Darmwal
Kuldeep Darmwal

Reputation: 185

For accessing GLOBAL|SESSION VARIABLES try with command in MYSQL:

$ GRANT ALL ON sonar.* TO 'sonar'@'%' IDENTIFIED BY 'sonar';

$ GRANT ALL ON sonar.* TO 'sonar'@'localhost' IDENTIFIED BY 'sonar';

If it is not working then you should try(It only provide SELECT permission to 'sonar' user for all DATABASES):

$ GRANT SELECT ON . TO 'sonar'@'%' IDENTIFIED BY 'sonar';

$ GRANT SELECT ON . TO 'sonar'@'localhost' IDENTIFIED BY 'sonar';

It provides permission to sonar user to access all the databases with all the privilege SELECT,INSERT,UPDATE,DELETE (ALL possible moves on DB).

$ GRANT ALL ON . TO 'sonar'@'%' IDENTIFIED BY 'sonar';

$ GRANT ALL ON . TO 'sonar'@'localhost' IDENTIFIED BY 'sonar';

Upvotes: 0

Nicolas B.
Nicolas B.

Reputation: 7321

Your SonarQube server connects to the database with a user ('sonar_user'@'localhost') who does not have sufficient privileges (as per error message, it cannot issue SELECT commands in the database).

You need to grant this permission to this user in the MySQL DB (here's a helpful tutorial on how to achieve that).

Upvotes: 4

Related Questions