<commit_before>[[createdb]]
== Database Setup

During the init phase of Gerrit you will need to specify which database to use.

[[createdb_h2]]
=== H2

If you choose H2, Gerrit will automatically set up the embedded H2 database as
backend so no set up or configuration is necessary.

Using the embedded H2 database is the easiest way to get a Gerrit
site up and running, making it ideal for proof of concepts or small team
servers.  On the flip side, H2 is not the recommended option for large
corporate installations. This is because there is no easy way to interact
with the database while Gerrit is offline, it's not easy to backup the data,
and it's not possible to set up H2 in a load balanced/hotswap configuration.

If this option interests you, you might want to consider link:install-quick.html[the quick guide].

[[createdb_derby]]
=== Apache Derby

If Derby is selected, Gerrit will automatically set up the embedded Derby
database as backend so no set up or configuration is necessary.

Currently only support for embedded mode is added. There are two other
deployment options for Apache Derby that can be added later:

* link:http://db.apache.org/derby/papers/DerbyTut/ns_intro.html#Network+Server+Options[
Derby Network Server (standalone mode)]

* link:http://db.apache.org/derby/papers/DerbyTut/ns_intro.html#Embedded+Server[
Embedded Server (hybrid mode)]

[[createdb_postgres]]
=== PostgreSQL

This option is more complicated than the H2 option but is recommended
for larger installations. It's the database backend with the largest userbase
in the Gerrit community.

Create a user for the web application within PostgreSQL, assign it a
password, create a database to store the metadata, and grant the user
full rights on the newly created database:

----
  $ createuser --username=postgres -RDIElPS gerrit2
  $ createdb --username=postgres -E UTF-8 -O gerrit2 reviewdb
----

Visit PostgreSQL's link:http://www.postgresql.org/docs/9.1/interactive/index.html[documentation] for further information regarding
using PostgreSQL.

[[createdb_mysql]]
=== MySQL

Requirements: MySQL version 5.1 or later.

This option is also more complicated than the H2 option. Just as with
PostgreSQL it's also recommended for larger installations.

Create a user for the web application within the database, assign it a
password, create a database, and give the newly created user full
rights on it:

----
  mysql

  CREATE USER 'gerrit2'@'localhost' IDENTIFIED BY 'secret';
  CREATE DATABASE reviewdb;
  GRANT ALL ON reviewdb.* TO 'gerrit2'@'localhost';
  FLUSH PRIVILEGES;
----

Visit MySQL's link:http://dev.mysql.com/doc/[documentation] for further
information regarding using MySQL.

[[createdb_mariadb]]
=== MariaDB

Requirements: MariaDB version 5.5 or later.

Refer to MySQL section above how to create MariaDB database.

Visit MariaDB's link:https://mariadb.com/kb/en/mariadb/[documentation] for further<commit_msg>Doc: Set default character set for MySQL<commit_after>[[createdb]]
== Database Setup

During the init phase of Gerrit you will need to specify which database to use.

[[createdb_h2]]
=== H2

If you choose H2, Gerrit will automatically set up the embedded H2 database as
backend so no set up or configuration is necessary.

Using the embedded H2 database is the easiest way to get a Gerrit
site up and running, making it ideal for proof of concepts or small team
servers.  On the flip side, H2 is not the recommended option for large
corporate installations. This is because there is no easy way to interact
with the database while Gerrit is offline, it's not easy to backup the data,
and it's not possible to set up H2 in a load balanced/hotswap configuration.

If this option interests you, you might want to consider link:install-quick.html[the quick guide].

[[createdb_derby]]
=== Apache Derby

If Derby is selected, Gerrit will automatically set up the embedded Derby
database as backend so no set up or configuration is necessary.

Currently only support for embedded mode is added. There are two other
deployment options for Apache Derby that can be added later:

* link:http://db.apache.org/derby/papers/DerbyTut/ns_intro.html#Network+Server+Options[
Derby Network Server (standalone mode)]

* link:http://db.apache.org/derby/papers/DerbyTut/ns_intro.html#Embedded+Server[
Embedded Server (hybrid mode)]

[[createdb_postgres]]
=== PostgreSQL

This option is more complicated than the H2 option but is recommended
for larger installations. It's the database backend with the largest userbase
in the Gerrit community.

Create a user for the web application within PostgreSQL, assign it a
password, create a database to store the metadata, and grant the user
full rights on the newly created database:

----
  $ createuser --username=postgres -RDIElPS gerrit2
  $ createdb --username=postgres -E UTF-8 -O gerrit2 reviewdb
----

Visit PostgreSQL's link:http://www.postgresql.org/docs/9.1/interactive/index.html[documentation] for further information regarding
using PostgreSQL.

[[createdb_mysql]]
=== MySQL

Requirements: MySQL version 5.1 or later.

This option is also more complicated than the H2 option. Just as with
PostgreSQL it's also recommended for larger installations.

Create a user for the web application within the database, assign it a
password, create a database, and give the newly created user full
rights on it:

----
  mysql

  CREATE USER 'gerrit2'@'localhost' IDENTIFIED BY 'secret';
  CREATE DATABASE reviewdb DEFAULT CHARACTER SET 'utf8';
  GRANT ALL ON reviewdb.* TO 'gerrit2'@'localhost';
  FLUSH PRIVILEGES;
----

Visit MySQL's link:http://dev.mysql.com/doc/[documentation] for further
information regarding using MySQL.

[[createdb_mariadb]]
=== MariaDB

Requirements: MariaDB version 5.5 or later.

Refer to MySQL section above how to create MariaDB database.

Visit MariaDB's link:https://mariadb.com/kb/en/mariadb/[documentation] for further
{'fraction_non_alphanumeric': 0.0723728813559322, 'fraction_numerical': 0.006949152542372881, 'mean_word_length': 4.603988603988604, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4017817', 'n_tokens_mistral': 1744, 'n_tokens_neox': 1627, 'n_words': 767}