2012-12-05 16:53:24 +00:00
|
|
|
# Setup Database
|
2012-10-25 08:13:11 +00:00
|
|
|
|
2012-12-05 16:53:24 +00:00
|
|
|
GitLab supports the following databases:
|
|
|
|
|
|
|
|
* MySQL (preferred)
|
|
|
|
* PostgreSQL
|
2012-10-25 08:13:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
## MySQL
|
|
|
|
|
2012-12-05 16:53:24 +00:00
|
|
|
# Install the database packages
|
2012-10-25 08:13:11 +00:00
|
|
|
sudo apt-get install -y mysql-server mysql-client libmysqlclient-dev
|
|
|
|
|
2013-06-12 19:30:36 +00:00
|
|
|
# Pick a database root password (can be anything), type it and press enter
|
|
|
|
# Retype the database root password and press enter
|
|
|
|
|
2013-08-25 21:37:42 +00:00
|
|
|
# Secure your installation.
|
|
|
|
sudo mysql_secure_installation
|
|
|
|
|
2012-10-25 08:13:11 +00:00
|
|
|
# Login to MySQL
|
2013-02-27 22:09:14 +00:00
|
|
|
mysql -u root -p
|
2012-10-25 08:13:11 +00:00
|
|
|
|
2013-06-12 19:30:36 +00:00
|
|
|
# Type the database root password
|
|
|
|
|
|
|
|
# Create a user for GitLab
|
|
|
|
# do not type the 'mysql>', this is part of the prompt
|
|
|
|
# change $password in the command below to a real password you pick
|
2012-12-05 16:53:24 +00:00
|
|
|
mysql> CREATE USER 'gitlab'@'localhost' IDENTIFIED BY '$password';
|
|
|
|
|
2012-10-25 08:13:11 +00:00
|
|
|
# Create the GitLab production database
|
|
|
|
mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
|
|
|
|
|
2013-05-18 12:39:33 +00:00
|
|
|
# Grant the GitLab user necessary permissions on the table.
|
2013-04-05 16:01:19 +00:00
|
|
|
mysql> GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlab'@'localhost';
|
2012-10-25 08:13:11 +00:00
|
|
|
|
2012-12-05 16:53:24 +00:00
|
|
|
# Quit the database session
|
|
|
|
mysql> \q
|
|
|
|
|
|
|
|
# Try connecting to the new database with the new user
|
2013-02-15 09:52:10 +00:00
|
|
|
sudo -u git -H mysql -u gitlab -p -D gitlabhq_production
|
2012-10-25 08:13:11 +00:00
|
|
|
|
2013-06-12 19:30:36 +00:00
|
|
|
# Type the password you replaced $password with earlier
|
|
|
|
|
|
|
|
# You should now see a 'mysql>' prompt
|
|
|
|
|
|
|
|
# Quit the database session
|
|
|
|
mysql> \q
|
|
|
|
|
|
|
|
# You are done installing the database and can go back to the rest of the installation.
|
|
|
|
|
|
|
|
|
2012-10-25 08:13:11 +00:00
|
|
|
## PostgreSQL
|
|
|
|
|
2012-12-05 16:53:24 +00:00
|
|
|
# Install the database packages
|
2012-12-05 17:18:09 +00:00
|
|
|
sudo apt-get install -y postgresql-9.1 libpq-dev
|
2012-10-25 08:13:11 +00:00
|
|
|
|
2012-12-05 16:53:24 +00:00
|
|
|
# Login to PostgreSQL
|
2012-10-25 08:13:11 +00:00
|
|
|
sudo -u postgres psql -d template1
|
|
|
|
|
2012-12-05 16:53:24 +00:00
|
|
|
# Create a user for GitLab. (change $password to a real password)
|
2013-03-24 09:48:23 +00:00
|
|
|
template1=# CREATE USER git WITH PASSWORD '$password';
|
2012-10-25 08:13:11 +00:00
|
|
|
|
2012-10-30 11:58:10 +00:00
|
|
|
# Create the GitLab production database & grant all privileges on database
|
2013-03-24 09:48:23 +00:00
|
|
|
template1=# CREATE DATABASE gitlabhq_production OWNER git;
|
2012-10-25 08:13:11 +00:00
|
|
|
|
2012-12-05 16:53:24 +00:00
|
|
|
# Quit the database session
|
2012-10-25 08:13:11 +00:00
|
|
|
template1=# \q
|
|
|
|
|
2012-12-05 16:53:24 +00:00
|
|
|
# Try connecting to the new database with the new user
|
2013-02-15 09:52:10 +00:00
|
|
|
sudo -u git -H psql -d gitlabhq_production
|
2012-10-25 08:13:11 +00:00
|
|
|
|