Trending
  • Java 17 è arrivato
  • Microsoft lancia VSCode.Dev
  • Google Cloud Platform via Proxy
  • The Future of Java: Records, Sealed...
  • Come creare immagini Docker x86 (e altre!)...
NodeX
Navigate
  • Home
  • Cloud
  • Tools
  • DevOps
Docker con MySQL

Docker con MySQL

0
By Admin on Feb 4, 2021 Tools

Oggi vi proponiamo una guida veloce che vi permetterà di avviare MySQL con Docker inizializzando anche il database.

Immaginiamo che lo script di inizializzazione del database MySQL sia una cosa tipo questa:

CREATE DATABASE mydb;
GRANT ALL PRIVILEGES ON magento.* TO 'myuser'@'%' IDENTIFIED BY 'mysql';
GRANT ALL PRIVILEGES ON magento.* TO 'myuser'@'localhost' IDENTIFIED BY 'mysql';
USE magento
CREATE TABLE CONTACTS (
[ ... ]
);
INSERT INTO CONTACTS VALUES ...
[ ... ]

Copiamo il contenuto nel file init.sql

Sel nostro PC creiamo due folder con questa struttura simile a questa

/Users/nodex/Docker/volumes/Magento/mysql/data
/Users/nodex/Docker/volumes/Magento/mysql/init

Copiamo il nostro file nella directory init.

A questo punto potremo inizializzare il database all'avvio utilizzando questo comando:

docker run --name mysql1 \
-e MYSQL_ROOT_PASSWORD=password123 \
-e MYSQL_DATABASE=magento \
-v /Users/nodex/Docker/volumes/Magento/mysql/data:/var/lib/mysql
-v /Users/nodex/Docker/volumes/Magento/mysql/init:/docker-entrypoint-initdb.d/:ro
mysql:5.7

 

 

Tagged In News Mysql Docker Database 
Share Twitter Facebook Google+ Pinterest LinkedIn Tumblr Email
comments powered by Disqus
    • Popular
    • Recent
    • Hot
    • Comandi Kafka
      Jan 16, 2021 0 Comandi Kafka
    • GitHub Actions o Jenkins?
      Jan 21, 2021 0 GitHub Actions o Jenkins?
    • Come funzionano le Pull Request di GitHub
      Jan 21, 2021 0 Come funzionano le Pull Request di GitHub
    • The Future of Java: Records, Sealed Classes and Pattern...
      Nov 24, 2021 0 The Future of Java: Records, Sealed Classes and Pattern...
    • CNCF pubblica l'ultimo radar tecnologico incentrato su...
      Nov 22, 2021 0 CNCF pubblica l'ultimo radar tecnologico incentrato su...
    • Elaborazione degli eventi in tempo reale exactly-once su...
      Nov 15, 2021 0 Elaborazione degli eventi in tempo reale exactly-once su...
    • Come funzionano le Pull Request di GitHub
      Jan 21, 2021 0 Come funzionano le Pull Request di GitHub
    • Comandi Kafka
      Jan 16, 2021 0 Comandi Kafka
    • Google Cloud Platform via Proxy
      Jan 10, 2021 0 Google Cloud Platform via Proxy
  • Latest News

  • Latest Reviews

  • About

    NodeX

    DevOps News

    Parliamo di Cloud computing, Continuous Integration, Continuous Delivery, DevOps, Docker, Kubernetes, Terraform, GitHub e molto altro...

  • Popular Posts

    • Comandi Kafka
      Jan 16, 2021 0 Comandi Kafka
    • GitHub Actions o Jenkins?
      Jan 21, 2021 0 GitHub Actions o Jenkins?
    • Come funzionano le Pull Request di GitHub
      Jan 21, 2021 0 Come funzionano le Pull Request di GitHub
  • News Stream

    The Future of Java:...
    CNCF pubblica l'ultimo...
    Elaborazione degli eventi...
    Apache Spark porta l'API...
    GCE: Provided scope(s) are...
    Java Novembre 2021
    Java 17 è arrivato
    Microsoft lancia VSCode.Dev
    AWS annuncia la...
    Datadog monitoring per...
    Java - Observability con...
    I moduli in Terraform
Copyright © 2021. Powered by Powerpad CMS Reloaded
  • About
  • Privacy
  • Contact
Home Tools
^ Top