gpt4 book ai didi

mysql - Sonar 设置MYSQL

转载 作者:行者123 更新时间:2023-11-28 23:55:59 26 4
gpt4 key购买 nike

我正在尝试将默认数据库更改为 MYSQL。我使用了一些教程,比如 http://laurenthinoul.com/how-to-change-sonar-default-database/ .Mysql 数据库已创建并运行。

我的问题是文件夹 ..sonarqube\sonarqube-5.1.1\conf 默认文件 sonar.properties 中的文件所有配置都被注释我尝试取消注释 mysql 驱动程序,但它不起作用。我的问题为什么默认数据库被注释,以及如何更改为Mysql。

# DATABASE
#
# IMPORTANT: the embedded H2 database is used by default. It is recommended for tests but not for
# production use. Supported databases are MySQL, Oracle, PostgreSQL and Microsoft SQLServer.

# User credentials.
# Permissions to create tables, indices and triggers must be granted to JDBC user.
# The schema must be created first.
#sonar.jdbc.username=sonar
#sonar.jdbc.password=sonar

#----- Embedded Database (default)
# It does not accept connections from remote hosts, so the
# server and the analyzers must be executed on the same host.
#sonar.jdbc.url=jdbc:h2:tcp://localhost:9092/sonar

# H2 embedded database server listening port, defaults to 9092
#sonar.embeddedDatabase.port=9092


#----- MySQL 5.x
# Only InnoDB storage engine is supported (not myISAM).
# Only the bundled driver is supported.
#sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance

然后我尝试访问 localhost:9000/setup 我得到了错误

迁移失败:发生错误,所有后续迁移均已取消:ActiveRecord::JDBCError: 表 'rule_tags' 已存在:CREATE TABLE rule_tags (id int(11 ) auto_increment PRIMARY KEY, tag varchar(100)) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin 。请检查日志。

日志:

2015.07.28 21:18:21 INFO  web[DbMigration] ==  AddRuleTags: migrating ====================================================
2015.07.28 21:18:21 INFO web[DbMigration] -- create_table(:rule_tags, {})
2015.07.28 21:18:21 ERROR web[o.s.s.ui.JRubyFacade] Fail to upgrade database
An error has occurred, all later migrations canceled:

ActiveRecord::JDBCError: Table 'rule_tags' already exists: CREATE TABLE `rule_tags` (`id` int(11) auto_increment PRIMARY KEY, `tag` varchar(100)) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin
E:/sonarqube/sonarqube-5.1.1/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract_adapter.rb:227:in `log'
E:/sonarqube/sonarqube-5.1.1/web/WEB-INF/gems/gems/activerecord-jdbc-adapter-1.1.3/lib/arjdbc/jdbc/adapter.rb:183:in `execute'
E:/sonarqube/sonarqube-5.1.1/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract/schema_statements.rb:109:in `create_table'
E:/sonarqube/sonarqube-5.1.1/web/WEB-INF/gems/gems/activerecord-jdbc-adapter-1.1.3/lib/arjdbc/mysql/adapter.rb:252:in `create_table'
org/jruby/RubyKernel.java:2231:in `send'
E:/sonarqube/sonarqube-5.1.1/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:352:in `method_missing'
E:/sonarqube/sonarqube-5.1.1/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:328:in `say_with_time'
jar:file:/E:/sonarqube/sonarqube-5.1.1/lib/server/jruby-complete-1.7.9.jar!/META-INF/jruby.home/lib/ruby/1.8/benchmark.rb:293:in `measure'
E:/sonarqube/sonarqube-5.1.1/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:328:in `say_with_time'
E:/sonarqube/sonarqube-5.1.1/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:348:in `method_missing'
E:/sonarqube/sonarqube-5.1.1/web/WEB-INF/config/environment.rb:194:in `create_table'
E:/sonarqube/sonarqube-5.1.1/web/WEB-INF/config/../lib/../db/migrate/489_add_rule_tags.rb:27:in `up'
org/jruby/RubyKernel.java:2223:in `send'
E:/sonarqube/sonarqube-5.1.1/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:282:in `migrate'
jar:file:/E:/sonarqube/sonarqube-5.1.1/lib/server/jruby-complete-1.7.9.jar!/META-INF/jruby.home/lib/ruby/1.8/benchmark.rb:293:in `measure'
E:/sonarqube/sonarqube-5.1.1/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:282:in `migrate'
org/jruby/RubyKernel.java:2227:in `send'
E:1:in `migrate'
E:/sonarqube/sonarqube-5.1.1/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:491:in `migrate'
org/jruby/RubyProc.java:290:in `call'
org/jruby/RubyProc.java:224:in `call'
E:/sonarqube/sonarqube-5.1.1/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:576:in `ddl_transaction'
E:/sonarqube/sonarqube-5.1.1/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:490:in `migrate'
org/jruby/RubyArray.java:1613:in `each'
E:/sonarqube/sonarqube-5.1.1/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:477:in `migrate'
E:/sonarqube/sonarqube-5.1.1/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:401:in `up'
E:/sonarqube/sonarqube-5.1.1/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/migration.rb:383:in `migrate'
E:/sonarqube/sonarqube-5.1.1/web/WEB-INF/config/../lib/database_version.rb:62:in `upgrade_and_start'
E:/sonarqube/sonarqube-5.1.1/web/WEB-INF/app/models/database_migration_manager.rb:109:in `start_migration'
org/jruby/RubyProc.java:290:in `call'
org/jruby/RubyProc.java:228:in `call'

最佳答案

SonarQube 从默认数据库 H2 开始,即使没有定义 sonar.jdbc.url 设置。取消注释 MySQL 配置 (#sonar.jdbc.url=jdbc:mysql...) 并更新 url 是一件好事。

我可以确认您的 Sonarqube 服务器可以很好地使用 MySQL,因为我可以在日志中看到 ENGINE=InnoDB,这是特定于 MySQL 的。

正如错误所说的那样,该表已经存在,也许您已经尝试从这个模式开始,但它未能结束,然后您重试了?如果是这样,我鼓励您从一个新的模式重新开始。

为了能够帮助到您更多,请将完整的日志发送给您。

关于mysql - Sonar 设置MYSQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31683158/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com