As our GitlabHQ setup at SRMvision is mean to stay, we wanted to migrate from the standard SQLite database to an easier to manage for us : mySQL.
The steps are quite straighforward, first, setup mySQL :
create database gitlab; grant all privileges on gitlab.* to "gitlab" identified by "gitlab"; flush privileges;
Then prepare to dump the data out of GitlabHQ, stop your webserver, then, from your GitlabHQ folder :
bundle exec rake db:data:dump RAILS_ENV=production
this will create a db/data.yml file. All you have to do now is reconfigure GitlabHQ to connect to mySQL and reimport the data. The database configuration takes place in the config/database.yml file, backup your existing file and rename the database.yml.example :
mv config/database.yml config/database.yml.old cp config/database.yml.example config/database.yml
Then edit the file to reflect your new configuration, only the production section is relevant in our case :
development: adapter: mysql2 encoding: utf8 reconnect: false database: gitlabhq_development pool: 5 username: root password: "secure password" # socket: /tmp/mysql.sock # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". # Do not set this db to the same as development or production. test: adapter: mysql2 encoding: utf8 reconnect: false database: gitlabhq_test pool: 5 username: root password: "secure password" # socket: /tmp/mysql.sock production: adapter: mysql2 encoding: utf8 reconnect: true # allows to autoreconnect if the mysql service restarts database: gitlab # to replace with your database name pool: 5 username: gitlab # to replace with your credentials password: "gitlab" # to replace with your credentials socket: /var/run/mysqld/mysqld.sock # mysql socket location on debian
Once this is done, you have to create the schema and restore your data :
bundle exec rake db:setup RAILS_ENV=production bundle exec rake db:data:load RAILS_ENV=production
Job’s done, you just need to restart the GitlabHQ server now (nginx, apache…). If you encounter a problem and this does not work as expected, you just have to restore the database.yml.old file to go back to SQLite.
