I need help with setting up Gitlab CI/CD for hosting MySQL database

I am currently unable to set up CI/CD for hosting MySQL database. Is anyone able to help me out? Thanks.

This is what my gitlab-ci.yaml looks like but it’s returning mysql: unrecognized service
ERROR: Job failed: exit code 1

  - prepare
  - test

  - mariadb


  stage: prepare
  image: mysql
  - apt-get update && apt-get --assume-yes install mysql-server mysql-common mysql-client
  - service mysql start
  - echo "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('password');" | mysql -u root
  - echo "SELECT 'OK';" | mysql -uroot -p"$MYSQL_ROOT_PASSWORD" -h mysql "$MYSQL_DATABASE"
  - mysql -uroot -p"$MYSQL_ROOT_PASSWORD" -h localhost < "data/db/scripts/create-db.sql"
  - mysql -uroot -p"$MYSQL_ROOT_PASSWORD" -h localhost < "data/db/scripts/init-db-tables.sql"

  stage: test
  image: java:opendjdk-8
    - ./gradlew assemble
    - ./gradlew check

I see that the mysql image doesn’t have a service file. The command which is given seems to be /usr/sbin/mysqld (this is, however, more a question for the mysql image)

I’ve decided to use PostgreSQL however, how do I know how much data I can store in the database and since Gitlab only allows you to host static website, how do I allow querying of the database from my application?

I don’t know how gitlab.com manages this. I would suspect that the CI/CD environment is not meant for having a database running continuously (but maybe I misunderstood your intentions).

Alright thanks. Have you worked with databases before? Where do you normally host it and do you use MySQL or PostgreSQL?

Yes, I’ve worked with both mysql ans postgresql. I think the usermanagement of mysql feels a bit more natural to me, but that’s just a matter of more experience with Mysql.
Normally I run it on a VM, sometimes in a docker container which has a data dir mounted, but you could probably also use a database system as provided by a cloud service. I use databases mostly work related, so then the virtualization layer is provided by a supplier, but you could use any VM service.

Do you have any recommendations of which VM services? Do you have telegram? Would love to speak with you more on this topic since you’ve experienced in it

no telegram and I don’t have much insight in the different providers, as my employers mostly chose those for very specific reasons. You might check regionally, there are a lot of providers, I would choose something in your own country, so communications and administration/legal stuff is simpler.

What about discord? What you said is true and I’ve tried Heroku and it seems like the one I’m looking for, however, it doesn’t have any server in my region so I wouldn’t be able to speed up the process when querying data from my database

no experience with discord or heroku, it doesn’t matter that much where your db server is, as long as it is relatively close to the node where you perform the db query, also depends on how much data actually gets transferred (mainly the query results).
I don’t think this is the place to discuss providers, it depends a lot of what you want to do with. Besides that I don’t have experience with a lot of different providers, so do not feel suited for any advise on this.

Alright then. Thanks for your help anyway. I appreciate it :slight_smile: