报错信息

2023-08-15T19:24:54.516978789+08:00 java.sql.SQLSyntaxErrorException: SELECT command denied to user 'test'@'192.170.1.191' for table 'user_variables_by_thread'
2023-08-15T19:24:54.516983618+08:00 	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120)
2023-08-15T19:24:54.516987048+08:00 	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
2023-08-15T19:24:54.516990372+08:00 	at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
2023-08-15T19:24:54.516993467+08:00 	at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:953)
2023-08-15T19:24:54.516996773+08:00 	at com.mysql.cj.jdbc.ClientPreparedStatement.executeQuery(ClientPreparedStatement.java:1003)
2023-08-15T19:24:54.516999778+08:00 	at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_executeQuery(FilterChainImpl.java:3240)
2023-08-15T19:24:54.517002871+08:00 	at com.alibaba.druid.filter.FilterEventAdapter.preparedStatement_executeQuery(FilterEventAdapter.java:465)
2023-08-15T19:24:54.517005876+08:00 	at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_executeQuery(FilterChainImpl.java:3237)
2023-08-15T19:24:54.517009262+08:00 	at com.alibaba.druid.proxy.jdbc.PreparedStatementProxyImpl.executeQuery(PreparedStatementProxyImpl.java:181)
2023-08-15T19:24:54.517012193+08:00 	at com.alibaba.druid.pool.DruidPooledPreparedStatement.executeQuery(DruidPooledPreparedStatement.java:227)
2023-08-15T19:24:54.517015206+08:00 	at org.flywaydb.core.internal.jdbc.JdbcTemplate.queryForStringList(JdbcTemplate.java:119)
2023-08-15T19:24:54.517018285+08:00 	at org.flywaydb.core.internal.database.mysql.MySQLConnection.hasUserVariableResetCapability(MySQLConnection.java:84)
2023-08-15T19:24:54.517021587+08:00 	at org.flywaydb.core.internal.database.mysql.MySQLConnection.<init>(MySQLConnection.java:54)
2023-08-15T19:24:54.517024507+08:00 	at org.flywaydb.core.internal.database.mysql.MySQLDatabase.doGetConnection(MySQLDatabase.java:162)
2023-08-15T19:24:54.517027487+08:00 	at org.flywaydb.core.internal.database.mysql.MySQLDatabase.doGetConnection(MySQLDatabase.java:40)
2023-08-15T19:24:54.517031440+08:00 	at org.flywaydb.core.internal.database.base.Database.getConnection(Database.java:122)
2023-08-15T19:24:54.517034930+08:00 	at org.flywaydb.core.internal.database.base.Database.getMainConnection(Database.java:315)
2023-08-15T19:24:54.517039118+08:00 	at org.flywaydb.core.Flyway.prepareSchemas(Flyway.java:550)
2023-08-15T19:24:54.517042316+08:00 	at org.flywaydb.core.Flyway.execute(Flyway.java:487)
2023-08-15T19:24:54.517056825+08:00 	at org.flywaydb.core.Flyway.migrate(Flyway.java:149)
......

解决方法

使用root用户对访问用户进行正确授权

GRANT SELECT ON  `performance_schema`.user_variables_by_thread TO test@'%';

参考

Flyway 官方文档