Config CircleCI for mysql database

I am unable to setup build for my laravel project with mysql db.

I’m sorry to hear that.

(I guess you intended to show us your Circle config and any error messages you get - unfortunately my crystal ball has run out of batteries, so we’re just going to have to help the non-supernatural way).


Can you share your config and any error messages that you get? Please take a look at this post for how to get help faster in the future.

version: 2

      - image: circleci/php:7.1-node-browsers
          MYSQL_DB: mate
          MYSQL_USER: root
      - image: mysql:5.7
        command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_bin --innodb-large-prefix=true --innodb-file-format=Barracuda
          MYSQL_USER: root

    working_directory: ~/laravel

      - checkout
      - run: sudo apt install -y libsqlite3-dev zlib1g-dev
      - run: sudo docker-php-ext-install zip
      - run: sudo composer self-update
      - restore_cache:
            - composer-v1-{{ checksum "composer.lock" }}
            - composer-v1-
      - run: composer install --dev --ignore-platform-reqs
      - save_cache:
          key: composer-v1-{{ checksum "composer.lock" }}
            - vendor
      - run:
          name: Mysql database
          command: mysql  -h -u root -e "create database mate;"
      - run: cp .env.travis .env
      - run: php artisan key:generate
      - run: php artisan migrate
      - run: mkdir -p build/logs
      - run: php vendor/bin/phpunit tests/ --coverage-clover build/logs/clover.xml
      - run: php vendor/bin/phpcbf --standard=ruleset.xml app/
      - run: php vendor/bin/phpcs --standard=ruleset.xml app/

It shows the error mysql not found and can you pls let me know how to write code for continuous deployment on DigitalOcean droplet.

I’m guessing the answer is in the manual (see the bolded part):

It is possible to specify multiple images for your job. Specify multiple images if, for example, you need to use a database for your tests or for some other required service. In a multi-image configuration job, all steps are executed in the container created by the first image listed.

So, you are trying to run the mysql binary on the first container, when MySQL is installed only on the second container.

To solve this, add a new run line after checkout which does something like:

sudo apt install -y mysql-client

You only need the client here, rather than a full server.

Thanks alot, It works and please help me in deployment on digitalocean droplet.


That’s not a question, that’s a request for free private tuition :wink:

My answer is “no”, of course, but if you make a solid effort to try getting a CD working based on the excellent documentation, and then ask a specific and focussed question if you have exhausted every other avenue, then someone will be pleased to help.

Good luck!


While the following advice was written for Stack Overflow, it is a a very worthwhile read, even if it is a bit hyperbolic: How much research effort is expected of Stack Overflow users? I think it is relevant to all volunteer-powered fora on the web.

1 Like

We now have docs explaining how to use MySQL with CircleCI

As our docs are open-source, suggestions and improvements are welcome. There is a link at the bottom of every page to open a PR or Issue.