Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,298,600
Community Members
 
Community Events
165
Community Groups

Is it possible to set collation and charset to MySQL service in Bitbucket Pipeline?

Edited

I use MySQL database in Bitbucket build pipeline defined like this:

definitions:
services:
mysql:
image: mysql:5.7
variables:
MYSQL_DATABASE: testbase
MYSQL_ROOT_PASSWORD: pass

But it use wrong (default) charset and collation. I need UTF-8 to get rid of exceptions like:

SQLException: Incorrect string value: '\xC5\x88' for column 'city' at row 1

Is there a way to fix it in bitbucket-pipelines.yml? In a standard Docker setup I can fix it this way:

database:
image: mysql:5.7
environment:
MYSQL_DATABASE: testbase
MYSQL_ROOT_PASSWORD: pass
command: [ 'mysqld', '--character-set-server=utf8', '--collation-server=utf8_general_ci' ]

 

2 answers

2 accepted

1 vote
Answer accepted

In the end, I have used another solution. It seems not possible to create MySQL service in Bitbucket using proper charset & collation. But it is possible to use SQL script to fix it just on database schema level:

alter database my_database_name
character set utf8
collate utf8_general_ci;

I use the database just for my automated integration tests. So I have set Liquibase to start DB initialization with setting proper charset & collation.

In case you prefer to do it on table level because you are no allowed to alter whole database schema you can use:

create table my_table (...
) character set utf8 collate utf8_general_ci;

Thank you Martin for posting the solution that you used.

1 vote
Answer accepted

Hi @mullermartin,

At the moment I'm afraid that it is not possible to pass a command to a Docker service container, like in the example you included.

We have a feature request about this in our issue tracker:

If you'd be interested in this, I would suggest that you add your vote in that request (by selecting the Vote for this issue link) as the number of votes helps the development team and product managers better understand the demand for new features. You are more than welcome to leave any feedback, and you can also add yourself as a watcher (by selecting the Start watching this issue link) if you'd like to get notified via email on updates.

In the meantime, a way to work around this issue would be to create a custom Docker image (based on the official mysql image) that sets your own CMD value, or supports environment variables for settings like these.

Kind regards,
Theodora

Thank you for the link and the solution proposal. I have upvoted the issue.

 

Regards,

Martin

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

Git push size limits are coming to Bitbucket Cloud starting April 4th, 2022

Beginning on April 4th, we will be implementing push limits. This means that your push cannot be completed if it is over 3.5 GB. If you do attempt to complete a push that is over 3.5 GB, it will fail...

2,231 views 2 9
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you