Reputation: 98
I get this error when I'm using post man for get response from my API.
java.sql.SQLSyntaxErrorException: SELECT command denied to user '<userid>'@'<my-pc-ip-address>' for table '<table-name>'
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120) ~[mysql-connector-java-8.0.16.jar:8.0.16]
but I can use SELECT Statement perfectly in Workbench with the same user.
application.properties
spring.datasource.url = jdbc:mysql://<database.ip>:3306/<database.schema>
spring.datasource.username = test
spring.datasource.password = test123
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
I'm trying to using root account but I get this error
java.sql.SQLSyntaxErrorException : Unknown database '<db_name>'
I can solve this issue with this
@Table (table = "tablename") instead
@Table(table = "tablename", catalog = "catalogname" schema)
place this thing to application.properties
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
Upvotes: 0
Views: 2256
Reputation: 21
Just like Simon says above, the user 'test' doesn't have the right privileges to perform a 'SELECT' operation.
Upvotes: 1
Reputation: 36143
The user "test" is not granted to access the database.
You have to grant it first
Please find the grant command in the manual https://dev.mysql.com/doc/refman/8.0/en/grant.html
Upvotes: 1