javamysqlschemaspy

How to debug connection problem for SchemaSpy with MySQL (using password: NO)?


I have a no-login variant of mysql running on my machine. So I just type mysql for getting a mysql client shell.

No when I am trying to let SchemaSpy connect to mysql it fails:

# 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.

So the point is Access denied for user 'bodo'@'localhost' (using password: NO)

How can I debug this or how do I need to change my MySQL setup in order to let SchemaSpy run?


Solution

  • I have solved the connection problem by granting the user in question access to the database and by using a password.

    When you have this situation:

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

    and you have no anonymous user

    this can help:

    Do not forget to FLUSH PRIVILEGES;.

    Then you should be able to use:

    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>
    

    References

    AskUbuntu, SO1, SO2, Docs.