MAC OS X, Linux, Windows and other IT Tips and Tricks

20 Dec 16 Switch database type from H2 to MySQL in Atlassian Jira


After having tested Jira and decided to keep it for production it is very recommended to change the type of database used by Jira. The default database at delivery time is H2(local file dB) and in this HOW-TO I describe what I had to do to execute that switch under Debian Jessie.



Backup database:
(SprocketWheelIcon)==>>System ==>>(Left menu)Backup System ==>>Filename:
eg. /var/atlassian/application-data/jira/export/

Create the new Database in MySQL:
Follow theses instructions:
1) Connect to mysql as root:
mysql -p -u root
PW: ******

2) Create the DB, user and user access rights:
flush privileges;

3) Tip: To confirm if the permissions were granted successfully, log into the DB server with the JIRA DB user and run the command below:
SHOW GRANTS FOR 'jiradbuser'@'localhost';
4) Quit Mysql:
Stop Mysql server and Jira:
service mysql stop
service jira stop

Delete the innoDB log files
IMPORTANT!! Mke sure you have no other application that uses innoDB format for its databases otherwise that deletion might do data corruption.
rm /var/lib/mysql/ib_logfile?
Edit /etc/mysql/my.cnf and add the following lines:
FOR Mysql 5.5 and below

FOR Mysql 5.6

Remove this if it exists
Start MySQL server:
service mysql start
Install the MySQL JDBC driver to Jira drivers directory
cd /tmp
tar fvxz mysql-connector-java-5.1.40.tar.gz
cp mysql-connector-java-5.1.40/mysql-connector-java-5.1.40-bin.jar /opt/atlassian/jira/lib/
# Delete the not needed uncompressed directory
rm -rf mysql-connector-java-5.1.40

Connecting Jira to MySQL database:
Rename the dbconfig.xml file as follows:
Note: this change of filename will force Jira to start the Setup Wizzard if it doesn’t find this file.
mv /var/atlassian/application-data/jira/dbconfig.xml /var/atlassian/application-data/jira/dbconfig.xml.H2
Restart Jira:
Note: It is normally a long process that might take up to a minute before Jira can really be ready to be used.
service jira stop && service jira start && tail -f /var/atlassian/application-data/jira/log/atlassian-jira.log
Watch for errors(like ‘exception…’
When the logs are showing something like below then Jira is ready to be used to continue the migration of the database.
Heap memory : Used: 196 MiB. Committed: 482 MiB. Max: 733 MiB
Non-heap memory : Used: 57 MiB. Committed: 59 MiB. Max: 1264 MiB
TOTAL : Used: 253 MiB. Committed: 541 MiB. Max: 1997 MiB

Connecting Jira to the MySQL database:
– Using the browser go to this Jira site and you will be presented with the Jira setup wizzard.
– Select the Manual Setup
– At database Setup page select: My Own Database and fill in the blanks
– Click on Test Connection to verify the validity of the information
– If all ok, click on Continue button.
– Enter the Company name and Select Private,and give the URL in the ‘Set up application properties’ page
– Select I have a Jira Key and paste the key in the field below the Server ID
– And fill in the following pages etc.

Migrating the database
Importing from older H2 data saved in xml backup (.zip)file
In Terminal:
Move the backup file to the import directory:
mv /var/atlassian/application-data/jira/export/ /var/atlassian/application-data/jira/import/
In Jira site:
(SprocketWheelIcon)==>> System ==>> (Left menu)Restore System
Enter the filename(without path) of the backup(including the .zip extension)
Click Restore button.
IMPORTANT NOTE: This operation will overwrite all settings(except for the Database connection) which you already entered in the previous Setup Wizzard like your password/user/email/Language etc.. Therefore if this information are not exactly the same, you will have to logout and login again.

The Portfolio for Jira licence might have to be renewed at:

In order to correct the error, that will appear if the FLAG pool-test-while-idle is not set in the file dbconfig.xml, edit the file:
/var/atlassian/application-data/jira/dbconfig.xml and add the following line inside the settings block as follows:

Reason: The Set-up wizzard did not set it(inexistant) during its setting up the Database settings and the interface was complaining that it failed a database connection test. I had to make that change manually later and restart Jira.
Restart Jira and watch for errors.
service jira stop && service jira start && tail -f /var/atlassian/application-data/jira/log/atlassian-jira.log

Verifying the logs for errors:

You can check for errors via the Jira interface Log analyzer function in:
(SprocketWheelIcon)==>>System ==>>(Left menu)Support Tools==>>Log analyzer(TAB)==>>Refresh(middle right)

Leave a Reply

%d bloggers like this: