Trying to connect my arduino to MySql Database running in Docker


Disclaimer: Only Answer if you have knowledge about docker

I have MRKWIFi 1010 board. I am using RFID, MLX temp sensor and OLED Screen for my project.
I need to have access to MYSQL database which will be running in DOCKER, to store and retrieve data.

Arduino code attached
Here is the docker-compose file

version: "3"

      context: ./bin/${PHPVERSION}
    container_name: '${COMPOSE_PROJECT_NAME}-${PHPVERSION}'
    restart: 'always'
      - database
      - ${DOCUMENT_ROOT-./www}:/var/www/html
      - ${PHP_INI-./config/php/php.ini}:/usr/local/etc/php/php.ini
      - ${VHOSTS_DIR-./config/vhosts}:/etc/apache2/sites-enabled
      - ${LOG_DIR-./logs/apache2}:/var/log/apache2
      context: "./bin/${DATABASE}"
    container_name: '${COMPOSE_PROJECT_NAME}-database'
    restart: 'always'
      - "${HOST_MACHINE_MYSQL_PORT}:3306"
      - ${MYSQL_DATA_DIR-./data/mysql}:/var/lib/mysql
      - ${MYSQL_LOG_DIR-./logs/mysql}:/var/log/mysql
    image: phpmyadmin/phpmyadmin
    container_name: '${COMPOSE_PROJECT_NAME}-phpmyadmin'
      - database
      PMA_HOST: database
      PMA_PORT: 3306
      - '${HOST_MACHINE_PMA_PORT}:80'
      - /sessions
      - ${PHP_INI-./config/php/php.ini}:/usr/local/etc/php/conf.d/php-phpmyadmin.ini
    container_name: '${COMPOSE_PROJECT_NAME}-redis'
    image: redis:latest
      - "${HOST_MACHINE_REDIS_PORT}:6379"

I have tried putting all type of ips (webserver, sql databse, vm machine, host machine) in **char server**but nothing seems to work. i Cant connect to my server and database.
Please help !

Arduino COde.txt (8 KB)

See Arduino - MySQL tutorial

I’ve used Docker occasionally. I expect a few of the regular posters here have too, but I don’t recall it ever being mentioned here, so I wouldn’t expect that you’ll get your answer on this forum.

Also, the Arduino bit is fairly irrelevant - you can test your docker instance more easily with a regular PC. Don’t forget that MySQL config defaults to access from localhost only - if you want a remote device to access it directly you will need to fix the bind-address in config.

And don't be an idiot and use the root user to access the DB from Arduino directly or from a PHP webpage :wink:

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.