gitlab-org--gitlab-foss/doc/install/databases.md
Riyad Preukschas 78d3611eba Remove redundant packages and move database specific ones to the db setup
* build-essential requires make, gcc
* remove libmysql++-dev: the mysql2 gem only requires libmysqlclient-dev
* remove postgresql-server-dev-9.1: the pg gem only requires libpq-dev
* replace python-dev, python-pip with python2.7: the pygments.rb gem only requires python2.7
2012-12-05 18:18:09 +01:00

68 lines
2 KiB
Markdown

# Setup Database
GitLab supports the following databases:
* MySQL (preferred)
* PostgreSQL
## MySQL
# Install the database packages
sudo apt-get install -y mysql-server mysql-client libmysqlclient-dev
# Install only the necessary gems
sudo -u gitlab -H bundle install --deployment --without development test postgres
# Login to MySQL
$ mysql -u root -p
# Create a user for GitLab. (change $password to a real password)
mysql> CREATE USER 'gitlab'@'localhost' IDENTIFIED BY '$password';
# Create the GitLab production database
mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
# Grant the GitLab user necessary permissopns on the table.
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlab'@'localhost';
# Quit the database session
mysql> \q
# Try connecting to the new database with the new user
sudo -u gitlab -H mysql -u gitlab -p -D gitlabhq_production
## PostgreSQL
# Install the database packages
sudo apt-get install -y postgresql-9.1 libpq-dev
# Install only the necessary gems
sudo -u gitlab -H bundle install --deployment --without development test mysql
# Login to PostgreSQL
sudo -u postgres psql -d template1
# Create a user for GitLab. (change $password to a real password)
template1=# CREATE USER gitlab WITH PASSWORD '$password';
# Create the GitLab production database & grant all privileges on database
template1=# CREATE DATABASE gitlabhq_production OWNER gitlab;
# Quit the database session
template1=# \q
# Try connecting to the new database with the new user
sudo -u gitlab -H psql -d gitlabhq_production
# Configure GitLab
# Mysql
sudo -u gitlab cp config/database.yml.mysql config/database.yml
# PostgreSQL
sudo -u gitlab cp config/database.yml.postgresql config/database.yml
Make sure to update username/password in config/database.yml.