Skip to content
Custom cartridge for OpenShift providing MySQL 5.7.17
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Custom MySQL cartridge for OpenShift


This is a custom OpenShift cartridge providing the latest MySQL version (5.7.17 as of March 29 2017).


Because the standard OpenShift MySQL cartridge is stuck at 5.5 and some people are keen to use the latest MySQL server features (such as improved support for spatial data).

When to use

When you need a quick and unsofisticated solution to run your application with the latest MySQL version.


To install this cartridge in your existing OpenShift application, go to "See the list of cartridges you can add", paste the URL below in "Install your own cartridge" textbox at the bottom of the page and click "Next".

Setting up

Once the cartridge is created and started, you can SSH into the database gear:

ssh gear-url

...and connect to the server with mysql client like this:

${OPENSHIFT_DATA_DIR}.mysql/bin/mysql --socket=${TMP}mysql.sock -u root

If you really need it, you can enable remote access for root like this (make sure to replace secret with a strong password):

${OPENSHIFT_DATA_DIR}.mysql/bin/mysql --socket=${TMP}mysql.sock -u root -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'secret' WITH GRANT OPTION; FLUSH PRIVILEGES;"

If you're using multiple gears, here's how you can find the MySQL gear SSH url:

rhc app show application-name --gears

Once you've enabled remote access, you can use rhc port-forward and MySQL Workbench or your favorite client to connect from your development machine.

Use OPENSHIFT_MYSQL_DB_HOST and OPENSHIFT_MYSQL_DB_PORT environment variables to connect from an application running in the main web cartridge. For instance, here's how you'd do it in a Node.js application using Knex.js:

var knex = require('knex')({
  client: 'mysql',
  connection: {
    host     : process.env.OPENSHIFT_MYSQL_DB_HOST,
    port:    : process.env.OPENSHIFT_MYSQL_DB_PORT,
    user     : 'your_database_user',
    password : 'your_database_password',
    database : 'myapp_test'


  • Can't guarantee this cartridge is production-ready. Some people use it though (on their own responsibility).
  • This is a lean cartridge. A standard MySQL installation takes a huge amount of space (over 1.5GB for MySQL 5.7.5). To save space, just the necessary MySQL binaries are installed.
  • In order to avoid an OpenShift configuration conflict, the server instance is listening on 13306 instead of the standard MySQL port 3306.
  • Don't hesitate to make a pull-request with an updated version in this file if you notice this cartridge version is behind the latest MySQL release.
  • Don't open issues in this repository to ask questions about rhc port-forward. Please refer to the OpenShift documentation to learn about it. I am not an employee of RedHat / OpenShift, nor do I have any form of consultancy agreement with them and the fact that I open-sourced this cartridge doesn't mean I'm willing to offer free advice on the subject. Pull-requests and suggestions are always welcome, though.


Since you're here, chances are you might also be interested in this custom Node.js cartridge or this custom MongoDB cartridge.

Credits and attributions

This cartridge was inspired by Ted Wennmark's blog post on how to create a minimal MySQL installation for an embedded system.


See contributors here.

If you find this repo useful, don't hesitate to give it a star and spread the word.


The ISC License.

You can’t perform that action at this time.