Skip to content
Snippets Groups Projects
Select Git revision
  • ag-test
  • rs-test
  • master default protected
  • test-me-pa
  • mksionek-master-patch-52381
  • new-branch-10
  • test-conflicts
  • test-suggestions
  • alejandro-test
  • patch-25
  • winh-test-image-doscussion
  • stg-lfs-image-test-2
  • stg-lfs-image-test
  • test42016
  • issue_42016
  • issue-32709
  • add-codeowners
  • ClemMakesApps-master-patch-62759
  • bvl-staging-test
  • bvl-merge-base-api
  • v9.2.0-rc6 protected
  • v9.2.0-rc5 protected
  • v9.2.0-rc4 protected
  • v9.2.0-rc3 protected
  • v9.1.4 protected
  • v9.2.0-rc2 protected
  • v9.2.0-rc1 protected
  • v9.1.3 protected
  • v8.17.6 protected
  • v9.0.7 protected
  • v9.1.2 protected
  • v9.1.1 protected
  • v9.2.0.pre protected
  • v9.1.0 protected
  • v9.1.0-rc7 protected
  • v9.1.0-rc6 protected
  • v9.0.6 protected
  • v9.1.0-rc5 protected
  • v9.1.0-rc4 protected
  • v9.1.0-rc3 protected
40 results

database_mysql.md

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.

    Database MySQL

    Note

    We do not recommend using MySQL due to various issues. For example, case (in)sensitivity and problems that suggested fixes have.

    MySQL

    # Install the database packages
    sudo apt-get install -y mysql-server mysql-client libmysqlclient-dev
    
    # Ensure you have MySQL version 5.5.14 or later
    mysql --version
    
    # Pick a MySQL root password (can be anything), type it and press enter
    # Retype the MySQL root password and press enter
    
    # Secure your installation
    sudo mysql_secure_installation
    
    # Login to MySQL
    mysql -u root -p
    
    # Type the MySQL 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
    mysql> CREATE USER 'git'@'localhost' IDENTIFIED BY '$password';
    
    # Ensure you can use the InnoDB engine which is necessary to support long indexes
    # 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;
    
    # 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 permissions on the database
    mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, CREATE TEMPORARY TABLES, DROP, INDEX, ALTER, LOCK TABLES, REFERENCES ON `gitlabhq_production`.* TO 'git'@'localhost';
    
    # Quit the database session
    mysql> \q
    
    # Try connecting to the new database with the new user
    sudo -u git -H mysql -u git -p -D gitlabhq_production
    
    # 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.

    MySQL strings limits

    After installation or upgrade, remember to run the add_limits_mysql Rake task:

    Omnibus GitLab installations

    sudo gitlab-rake add_limits_mysql

    Installations from source

    bundle exec rake add_limits_mysql RAILS_ENV=production

    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!

    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).

    Details can be found in the PostgreSQL and MySQL manuals.