站点图标 星露谷值班站长

Gitlab 500报错解决

今天搭建了 Gitlab 项目启动后用浏览器访问显示 500 报错 500 是内部错误

解决方法:首先查看 gitlab 日志

查看错误日志

cat /home/git/gitlab/log/production.log

ActiveRecord::StatementInvalid (Mysql2::Error: Table ‘gitlabhq_production.projects’ doesn’t exist: SHOW FULL FIELDS FROM `projects`):
  config/initializers/connection_fix.rb:20:in `execute’
  app/controllers/application_controller.rb:196:in `add_gon_variables’
Mysql2::Error: Table ‘gitlabhq_production.projects’ doesn’t exist: SHOW FULL FIELDS FROM `projects`
Completed 500 Internal Server Error in 15ms (ActiveRecord: 5.0ms)
ActiveRecord::StatementInvalid (Mysql2::Error: Table ‘gitlabhq_production.projects’ doesn’t exist: SHOW FULL FIELDS FROM `projects`):
  config/initializers/connection_fix.rb:20:in `execute’
  app/controllers/application_controller.rb:196:in `add_gon_variables

可以看到日志里面是数据库报错

应该是初始化数据库并激活高级功能那一步哪里没有设定好 Mysql 的连接

bundle exec rake gitlab:setup RAILS_ENV=production GITLAB_ROOT_PASSWORD=123456

GITLAB_ROOT_PASSWORD 值为管理员 root 登录密码本例设为 123456

再次重启 Gitlab 就可以访问了

/etc/init.d/gitlab restart

成功解决!

 

 

 

 

退出移动版