2014-09-11 00:23:06 +00:00
# Database MySQL
2014-05-27 12:12:15 +00:00
2014-02-20 09:10:25 +00:00
## Note
2015-11-16 10:01:26 +00:00
We do not recommend using MySQL due to various issues. For example, case [(in)sensitivity ](https://dev.mysql.com/doc/refman/5.0/en/case-sensitivity.html ) and [problems ](https://bugs.mysql.com/bug.php?id=65830 ) that [suggested ](https://bugs.mysql.com/bug.php?id=50909 ) [fixes ](https://bugs.mysql.com/bug.php?id=65830 ) [have ](https://bugs.mysql.com/bug.php?id=63164 ).
2014-02-20 09:10:25 +00:00
## MySQL
2014-02-20 09:51:58 +00:00
# Install the database packages
sudo apt-get install -y mysql-server mysql-client libmysqlclient-dev
2016-01-18 21:53:33 +00:00
2014-03-08 00:57:05 +00:00
# Ensure you have MySQL version 5.5.14 or later
mysql --version
2014-02-20 09:10:25 +00:00
2014-09-11 00:23:06 +00:00
# Pick a MySQL root password (can be anything), type it and press enter
# Retype the MySQL root password and press enter
2014-02-20 09:10:25 +00:00
2014-09-11 00:23:06 +00:00
# Secure your installation
2014-02-20 09:51:58 +00:00
sudo mysql_secure_installation
2014-02-20 09:10:25 +00:00
2014-02-20 09:51:58 +00:00
# Login to MySQL
mysql -u root -p
2014-02-20 09:10:25 +00:00
2014-09-11 00:23:06 +00:00
# Type the MySQL root password
2014-02-20 09:10:25 +00:00
2014-02-20 09:51:58 +00:00
# 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
mysql> CREATE USER 'git'@'localhost' IDENTIFIED BY '$password';
2014-02-20 09:10:25 +00:00
2014-09-12 08:03:11 +00:00
# Ensure you can use the InnoDB engine which is necessary to support long indexes
2014-03-08 00:57:05 +00:00
# If this fails, check your MySQL config files (e.g. `/etc/mysql/*.cnf` , `/etc/mysql/conf.d/*` ) for the setting "innodb = off"
mysql> SET storage_engine=INNODB;
2016-01-18 21:53:33 +00:00
2014-02-20 09:51:58 +00:00
# Create the GitLab production database
mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci` ;
2014-02-20 09:10:25 +00:00
2014-09-12 08:03:11 +00:00
# Grant the GitLab user necessary permissions on the database
2015-09-18 17:49:04 +00:00
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, CREATE TEMPORARY TABLES, DROP, INDEX, ALTER, LOCK TABLES ON `gitlabhq_production` .* TO 'git'@'localhost';
2014-02-20 09:10:25 +00:00
2014-02-20 09:51:58 +00:00
# Quit the database session
mysql> \q
2014-02-20 09:10:25 +00:00
2014-02-20 09:51:58 +00:00
# Try connecting to the new database with the new user
sudo -u git -H mysql -u git -p -D gitlabhq_production
2014-02-20 09:10:25 +00:00
2014-02-20 09:51:58 +00:00
# Type the password you replaced $password with earlier
2014-02-20 09:10:25 +00:00
2014-02-20 09:51:58 +00:00
# You should now see a 'mysql>' prompt
2014-02-20 09:10:25 +00:00
2014-02-20 09:51:58 +00:00
# Quit the database session
mysql> \q
2014-02-20 09:10:25 +00:00
2014-02-20 09:51:58 +00:00
# You are done installing the database and can go back to the rest of the installation.
2016-01-18 14:52:26 +00:00
## MySQL strings limits
2016-01-18 21:53:33 +00:00
After installation or upgrade, remember to run the `add_limits_mysql` Rake task:
2016-01-18 14:52:26 +00:00
```
bundle exec rake add_limits_mysql
```
2016-01-18 21:53:33 +00:00
The `text` type in MySQL has a different size limit than the `text` type in
PostgreSQL. In MySQL `text` columns are limited to ~65kB, whereas in PostgreSQL
`text` columns are limited up to ~1GB!
2016-01-18 14:52:26 +00:00
2016-01-18 21:53:33 +00:00
The `add_limits_mysql` Rake task converts some important `text` columns in the
GitLab database to `longtext` columns, which can persist values of up to 4GB
(sometimes less if the value contains multibyte characters).
2016-01-18 14:52:26 +00:00
2016-01-18 21:53:33 +00:00
Details can be found in the [PostgreSQL][postgres-text-type] and
[MySQL][mysql-text-types] manuals.
2016-01-18 14:52:26 +00:00
[postgres-text-type]: http://www.postgresql.org/docs/9.1/static/datatype-character.html
[mysql-text-types]: http://dev.mysql.com/doc/refman/5.7/en/string-type-overview.html