为什么IntelliJ在使用本地数据源时无法找到db用户凭据?

时间:2013-09-28 23:13:03

标签: java mysql database intellij-idea

我已添加并且可以使用我的生产数据源而没有任何问题,但我在使用第二个“本地”数据源时遇到问题。我的连接设置如下所示:

数据库URL:jdbc:mysql:// localhost:3306 / <database_name>

用户:<username>

密码:<password>

测试连接成功,我可以看到表的列表,但无法读取表的内容。是的,该用户可以完全访问相关数据库;我在MySQL Workbench中证实了这一点。问题似乎是IntelliJ-IDEA特有的。

IntelliJ-IDEA因此抱怨:

java.sql.SQLException: SELECT command denied to user ''@'%' for column 'mycolumn'

通知user在错误消息中为''@'%'。出了什么问题?

同样,测试连接成功,我可以看到表的列表上述用户在MySQL Workbench中运行良好(可以选择/更新/插入所有表)。

我正在运行IntelliJ-IDEA版本12.1.4。

screenshot of error message

整个连接错误:

database_name.*
java.sql.SQLException: SELECT command denied to user ''@'%' for column 'column_name' in      table 'table_name'
  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:526)
  at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
  at com.mysql.jdbc.Util.getInstance(Util.java:386)
  at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054)
  at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4190)
  at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4122)
  at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2570)
  at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2731)
  at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2812)
  at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2761)
  at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1612)
  at com.mysql.jdbc.DatabaseMetaData$2.forEach(DatabaseMetaData.java:2571)
  at com.mysql.jdbc.DatabaseMetaData$2.forEach(DatabaseMetaData.java:2458)
  at com.mysql.jdbc.IterateBlock.doForAll(IterateBlock.java:51)
  at com.mysql.jdbc.DatabaseMetaData.getColumns(DatabaseMetaData.java:2457)
  at   com.intellij.persistence.jdbc.impl.RemoteDatabaseMetaDataImpl.getColumns(RemoteDatabaseMetaDataImpl.java:170)
  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:606)
  at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:322)
  at sun.rmi.transport.Transport$1.run(Transport.java:177)
  at sun.rmi.transport.Transport$1.run(Transport.java:174)
  at java.security.AccessController.doPrivileged(Native Method)
  at sun.rmi.transport.Transport.serviceCall(Transport.java:173)
  at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:556)
  at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:811)
  at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:670)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
  at java.lang.Thread.run(Thread.java:724)
  at   sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:275)
  at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:252)
  at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:161)
  at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:194)
  at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:148)
  at com.sun.proxy.$Proxy147.getColumns(Unknown Source)
  at sun.reflect.GeneratedMethodAccessor398.invoke(Unknown Source)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:606)
  at com.intellij.execution.rmi.RemoteUtil$RemoteInvocationHandler.invoke(RemoteUtil.java:211)
  at com.sun.proxy.$Proxy148.getColumns(Unknown Source)
  at com.intellij.javaee.dataSource.DatabaseSchemaLoader.loadTableBasicsInner(DatabaseSchemaLoader.java:998)
  at com.intellij.javaee.dataSource.DatabaseSchemaLoader.loadTableBasics(DatabaseSchemaLoader.java:961)
  at com.intellij.javaee.dataSource.DatabaseSchemaLoader.loadElementDetails(DatabaseSchemaLoader.java:891)
  at com.intellij.javaee.dataSource.DatabaseSchemaLoader.loadDataSourceState(DatabaseSchemaLoader.java:113)
  at com.intellij.javaee.dataSource.AbstractDataSource.refreshMetaData(AbstractDataSource.java:49)
  at com.intellij.javaee.dataSource.AbstractDataSource$1.perform(AbstractDataSource.java:27)
  at com.intellij.javaee.dataSource.AbstractDataSource$1.perform(AbstractDataSource.java:25)
  at com.intellij.javaee.dataSource.DataSource.performJdbcOperation(DataSource.java:296)
  at com.intellij.javaee.dataSource.AbstractDataSource.refreshMetaData(AbstractDataSource.java:25)
  at com.intellij.javaee.module.view.dataSource.DataSourceUiUtil$2.run(DataSourceUiUtil.java:120)
  at com.intellij.openapi.progress.impl.ProgressManagerImpl$TaskRunnable.run(ProgressManagerImpl.java:495)
  at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:185)
  at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:226)
  at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:175)
  at com.intellij.openapi.progress.impl.ProgressManagerImpl$8.run(ProgressManagerImpl.java:400)
  at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:454)
  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
  at java.util.concurrent.FutureTask.run(FutureTask.java:262)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
  at java.lang.Thread.run(Thread.java:724)
  at com.intellij.openapi.application.impl.ApplicationImpl$1$1.run(ApplicationImpl.java:152)

1 个答案:

答案 0 :(得分:2)

我有一个观点。正如another post(信用:@FooBarUser)所建议的,我将视图的'DEFINER'更改为有效的本地用户,问题解决了!