Configure Gitlab to use an external database

Source: Internet
Author: User
Tags create database

Change bundle_without: "Development:test:mysql" revision to
Bundle_without: "Development:test:postgres"

Yum-y Install Ruby-devel
./gem Install MYSQL2

1. Create a database

GRANT all privileges to gitlab.*to ' gitlab ' @ '% ' identified by ' Gitlab ' with GRANT OPTION;

Flush privileges;

2, configure GITLAB.RB, add MySQL

gitlab_rails[' db_adapter '] = "MYSQL2"
gitlab_rails[' db_encoding '] = "UTF8"
gitlab_rails[' db_database '] = "Gitlab"
gitlab_rails[' db_username '] = "Gitlab"
gitlab_rails[' db_password '] = "Gitlab"
gitlab_rails[' db_host '] = ""
gitlab_rails[' db_port '] = 3306
postgresql[' Enable '] = False

3. Configuring Gitlab Dependencies
3.1 Remove Postgres Dependency
#缺少 MYSQL2, use Ruby's Gem tool to download one, and before you download it, you'll need to configure Ruby and bundle
Replace the original MySQL with Postgres, we don't need the postgers package.
Write a picture description here

3.2 Installing MySQL Dependencies
Installation dependent, you need to specify the version, you can install the version after installation, Gitlab-rake Gitlab:check to view the installation.

Gitlab almost all of the commands are in this directory


# #安装mysql
./gem Install MYSQL2

Yum-y Install Ruby-devel

./gem Uninstall MYSQL2

./gem install mysql2-v "0.3.20"

./gem List | grep MySQL

4. Check the configuration
This check is to ensure that our configuration is absolutely correct. Otherwise, you will die very badly. This place will have a lot of wrong, can see my common problems, perhaps there is the same.

#查看配置是否ok, if the database is OK, you can directly execute Gitlab-rake gitlab:setup to create a table of the database.
Gitlab-rake Gitlab:check

5. Initialize Gitlab
Executes the Gitlab-rake gitlab:setup command to initialize the Gitlab.

Gitlab-rake Gitlab:setup

After we have executed the Gitlab-rake Gitlab:setup, we will be prompted that the previous data information will be lost. Of course we do not set to Yes, back to play AH.

Once successful, a root user is created

6. Restart Service
# # # # # # #后面几个gitlab-ctl Common commands, this configuration is not available
Gitlab-ctl reconfigure;

Gitlab-ctl Restart;

Gitlab-ctl Tail

7. View database Information
Can see the database, a lot more tables, and then the service started normally

Show tables;

Service starts normally

1, warehouse storage directory Permissions
The solution is to provide the warehouse with a GT user's privileges sudo chown-r git:git/var/opt/gitlab/git-data/repositories

Default ... no
User ID for git:995. GROUPD ID for git:993
Try Fixing it:
sudo chown-r git:git/var/opt/gitlab/git-data/repositories
For more information see:
Doc/install/ in section "GitLab Shell"
Please fix the error above and rerun the checks.

2, Gitlab no mysql2 dependence
Specified ' MYSQL2 ' for database adapter, but the gem was not loaded. Add to gem ‘mysql2‘ your gemfile (and ensure it version is in the minimum required by ActiveRecord). Excluded from capture due t o Environment or Should_capture callback
Workaround, install dependencies

#到bin目录下, execute the GEM's command

Gem install mysql2-v "0.3.20"

3, Gitlab can not find the problem of the table
If the driver installation succeeds, execute Gitlab-rake gitlab:check, if the table does not exist, you can execute the following code to create the table.

Gitlab-rake Gitlab:setup

4, Gitlab-shell self-check failed
The automatic check failed, causing the problem because the server was not found, and the solution was to point to its own server in the local hosts.
Solution,/etc/hosts add localhost, I'll test the function first.


#添加 localhost

Configure Gitlab to use an external database

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.