如何调试SchemaSpy与MySQL的连接问题(使用密码:NO)



我的机器上运行了一个无登录版本的mysql。所以我只需要键入mysql来获得mysql客户端shell。

不,当我试图让SchemaSpy连接到mysql时,它失败了:

# try with my user:
java -jar schemaSpy_5.0.0.jar -t mysql -dp /home/bodo/bin/mysql_conn/mysql-connector-java-5.1.49/mysql-connector-java-5.1.49-bin.jar -host localhost -u bodo -db ibo -o /home/bodo/bin/schemaspy/ibo
Using database properties:
[schemaSpy_5.0.0.jar]/net/sourceforge/schemaspy/dbTypes/mysql.properties
Thu Feb 10 17:01:05 CET 2022 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
Failed to connect to database URL [jdbc:mysql://localhost/ibo]
java.sql.SQLException: Access denied for user 'bodo'@'localhost' (using password: NO)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:965)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3933)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3869)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:864)
at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1707)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1217)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2189)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2220)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2015)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:768)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:403)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:385)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:323)
at net.sourceforge.schemaspy.SchemaAnalyzer.getConnection(SchemaAnalyzer.java:582)
at net.sourceforge.schemaspy.SchemaAnalyzer.analyze(SchemaAnalyzer.java:157)
at net.sourceforge.schemaspy.Main.main(Main.java:42)
# try without user does not work at all
bodo@bodo-work:~/bin/schemaspy$ java -jar schemaSpy_5.0.0.jar -t mysql -dp /home/bodo/bin/mysql_conn/mysql-connector-java-5.1.49/mysql-connector-java-5.1.49-bin.jar -host localhost -db ibo -o /home/bodo/bin/schemaspy/ibo
net.sourceforge.schemaspy.Config$MissingRequiredParameterException: Required parameter '-u' was not specified.

所以这一点是Access denied for user 'bodo'@'localhost' (using password: NO)

我该如何调试,或者我需要如何更改MySQL设置才能让SchemaSpy运行?

我通过授予有问题的用户访问数据库的权限并使用密码解决了连接问题。

当你遇到这种情况时:

mysql -u bodo
ERROR 1045 (28000): Access denied for user 'bodo'@'localhost' (using password: NO)

你没有匿名用户

这可以帮助:

  • ALTER USER 'bodo'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_pssw';
  • GRANT ALL PRIVILEGES ON *.* TO 'bodo'@'localhost' WITH GRANT OPTION;

不要忘记FLUSH PRIVILEGES;

然后你应该能够使用:

mysql -u bodo -p ibo -h localhost
Enter password: 
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 22
Server version: 8.0.28-0ubuntu0.20.04.3 (Ubuntu)
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
mysql>

参考

AskUbuntu,SO1,SO2,文档。

最新更新