Using Magic with MySQL

In this tutorial we will cover the following parts of Magic and Hyperlambda.

For reference purposes, and to be complete in our documentation, we’ve provided this guide of how to get started with Magic using MySQL - Even though MySQL is the database type in the default starter guide. Below is a complete docker-compose file, that creates a MySQL image in addition to the Magic backend and frontend.

version: "3.3"

services:

  db:
    image: mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: ThisIsNotAGoodPassword

  backend:
    image: aistamagic/magic-backend:latest
    depends_on:
      - db
    restart: always
    ports:
      - "4444:4444"
    volumes:
      - etc_magic_folder_my:/magic/files/etc
      - modules_magic_folder_my:/magic/files/modules
      - config_magic_folder_my:/magic/config

  frontend:
    image: aistamagic/magic-frontend:latest
    depends_on:
      - backend
    restart: always
    ports:
      - "5555:80"

volumes:
  etc_magic_folder_my:
  modules_magic_folder_my:
  config_magic_folder_my:

If you create a file named “docker-compose.yml” and save it to any directory on your machine with the above content, for then to run the following command in that same directory, this will start a MySQL instance on your machine.

docker-compose up

Configuring Magic

When you configure Magic, you’ll need to choose the “mysql” database type. Afterwards you’ll need to paste the following into its connection string settings.

Server=db;Database={database};Uid=root;Pwd=ThisIsNotAGoodPassword;SslMode=Preferred;Old Guids=true;

You also need to have Docker installed on your development machine.