
kettle连接mysql时出现问题
错误信息如下:
错误连接数据库 [test] : org.pentaho.di.core.exception.KettleDatabaseException:
Error occurred while trying to connect to the database Error connecting to database: (using class org.gjt.mm.mysql.Driver)
null, message from server: "Host '127.0.0.1' is not allowed to connect to this MySQL server" org.pentaho.di.core.exception.KettleDatabaseException:
Error occurred while trying to connect to the database Error connecting to database: (using class org.gjt.mm.mysql.Driver)
null, message from server: "Host '127.0.0.1' is not allowed to connect to this MySQL server" at org.pentaho.di.core.database.Database.normalConnect(Database.java:)
at org.pentaho.di.core.database.Database.connect(Database.java:)
at org.pentaho.di.core.database.Database.connect(Database.java:)
at org.pentaho.di.core.database.Database.connect(Database.java:)
at org.pentaho.di.core.database.DatabaseFactory.getConnectionTestReport(DatabaseFactory.java:)
at org.pentaho.di.core.database.DatabaseMeta.testConnection(DatabaseMeta.java:)
at org.pentaho.ui.database.event.DataHandler.testDatabaseConnection(DataHandler.java:)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:)
at java.lang.reflect.Method.invoke(Method.java:)
at org.pentaho.ui.xul.impl.AbstractXulDomContainer.invoke(AbstractXulDomContainer.java:)
at org.pentaho.ui.xul.impl.AbstractXulComponent.invoke(AbstractXulComponent.java:)
at org.pentaho.ui.xul.impl.AbstractXulComponent.invoke(AbstractXulComponent.java:)
at org.pentaho.ui.xul.swt.tags.SwtButton.access$(SwtButton.java:)
at org.pentaho.ui.xul.swt.tags.SwtButton$.widgetSelected(SwtButton.java:)
at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source)
at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:)
at org.eclipse.jface.window.Window.open(Window.java:)
at org.pentaho.ui.xul.swt.tags.SwtDialog.show(SwtDialog.java:)
at org.pentaho.ui.xul.swt.tags.SwtDialog.show(SwtDialog.java:)
at org.pentaho.di.ui.core.database.dialog.XulDatabaseDialog.open(XulDatabaseDialog.java:)
at org.pentaho.di.ui.core.database.dialog.DatabaseDialog.open(DatabaseDialog.java:)
at org.pentaho.di.ui.spoon.delegates.SpoonDBDelegate.newConnection(SpoonDBDelegate.java:)
at org.pentaho.di.ui.spoon.delegates.SpoonDBDelegate.newConnection(SpoonDBDelegate.java:)
at org.pentaho.di.ui.spoon.Spoon.doubleClickedInTree(Spoon.java:)
at org.pentaho.di.ui.spoon.Spoon.doubleClickedInTree(Spoon.java:)
at org.pentaho.di.ui.spoon.Spoon.access$(Spoon.java:)
at org.pentaho.di.ui.spoon.Spoon$.widgetDefaultSelected(Spoon.java:)
at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source)
at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
at org.pentaho.di.ui.spoon.Spoon.readAndDispatch(Spoon.java:)
at org.pentaho.di.ui.spoon.Spoon.waitForDispose(Spoon.java:)
at org.pentaho.di.ui.spoon.Spoon.start(Spoon.java:)
at org.pentaho.di.ui.spoon.Spoon.main(Spoon.java:)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:)
at java.lang.reflect.Method.invoke(Method.java:)
at org.pentaho.commons.launcher.Launcher.main(Launcher.java:)
Caused by: org.pentaho.di.core.exception.KettleDatabaseException:
Error connecting to database: (using class org.gjt.mm.mysql.Driver)
null, message from server: "Host '127.0.0.1' is not allowed to connect to this MySQL server" at org.pentaho.di.core.database.Database.connectUsingClass(Database.java:)
at org.pentaho.di.core.database.Database.normalConnect(Database.java:)
... more
Caused by: java.sql.SQLException: null, message from server: "Host '127.0.0.1' is not allowed to connect to this MySQL server"
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:)
at java.lang.reflect.Constructor.newInstance(Constructor.java:)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:)
at java.sql.DriverManager.getConnection(DriverManager.java:)
at java.sql.DriverManager.getConnection(DriverManager.java:)
at org.pentaho.di.core.database.Database.connectUsingClass(Database.java:)
... more
主机名 : localhost
端口 : 3306
数据库名:mysql
在网上搜了好多都说mysql-connector-java-5.1.26-bin没有在/data-integration/lib或者/data-integration/libswt/win64/下
但是上图可以看出我的jar包已在/data-integration/lib下
最后,解决方法是:
1. root使用密码123456(密码自己设置强度高点)从任何主机连接到mysql服务器的话。
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec) mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
2. 允许用户root从的主机连接到mysql服务器,并使用123456作为密码
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec) mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
3. 允许用户root从ip为127.0.0.2的主机连接到mysql服务器的dk数据库,并使用123456作为密码
mysql> GRANT ALL PRIVILEGES ON dk.* TO 'root'@'127.0.0.2' IDENTIFIED BY '' WITH GRANT OPTION; Query OK, 0 rows affected (0.00 sec) mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec)
授权完成后,再一次连接成功。