Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > it.comp.www.php > #22478

Re: importare database mysql dentro un contenitore (docker)

From sky winter <sky@bo.bo>
Newsgroups it.comp.www.php
Subject Re: importare database mysql dentro un contenitore (docker)
Date 2019-01-07 17:49 +0100
Organization Aioe.org NNTP Server
Message-ID <q0vvv7$8cv$1@gioia.aioe.org> (permalink)
References <q0vlro$omj$1@gioia.aioe.org> <g9h9i0F9t0rU1@mid.individual.net>

Show all headers | View raw


Il 07/01/19 16:29, Alessandro Pellizzari ha scritto:
> 
> Se usi "localhost" su un client MySQL (incluso PDO), lui cerca di 
> connettersi alla Unix socket

Cosa sarebbe?

> che, essendo in un container diverso, non è 
> accessibile.
> 
> Devi usare "mysql" (il nome che hai dato al container, che viene esposto 
> dal DNS fittizio di Docker) o 127.0.0.1 per forzarlo a usare la rete.

$ cat test.php
<?php
$pdo = new PDO(
     "mysql:host=127.0.0.1;dbname=test",
     'root','root1'
);

$query = $pdo->query("SELECT * FROM people");
var_dump($pdo->errorInfo());

foreach($query as $row ){
     var_dump($row);
}


$ docker run test-image php /usr/local/bin/test.php
Fatal error: Uncaught PDOException: SQLSTATE[HY000] [2002] Connection 
refused in /usr/local/bin/test.php:5

> Devi anche assicurarti che il container MySQL abbia la rete abilitata 
> (bind-address=0.0.0.0), ma dovrebbe essere così di default (altrimenti 
> non potresti usarlo... :D )

Tanto per sapere:
1. Come si fa a sapere la subnet mask in uso?
2. Come si fa a modificarla?

Back to it.comp.www.php | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

importare database mysql dentro un contenitore (docker) sky winter <sky@bo.bo> - 2019-01-07 14:57 +0100
  Re: importare database mysql dentro un contenitore (docker) Alessandro Pellizzari <shuriken@amiran.it> - 2019-01-07 15:29 +0000
    Re: importare database mysql dentro un contenitore (docker) sky winter <sky@bo.bo> - 2019-01-07 17:49 +0100
      Re: importare database mysql dentro un contenitore (docker) Alessandro Pellizzari <shuriken@amiran.it> - 2019-01-08 10:42 +0000
        Re: importare database mysql dentro un contenitore (docker) sky winter <sky@bo.bo> - 2019-01-08 13:34 +0100
          Re: importare database mysql dentro un contenitore (docker) Alessandro Pellizzari <shuriken@amiran.it> - 2019-01-08 13:25 +0000
            Re: importare database mysql dentro un contenitore (docker) sky winter <sky@bo.bo> - 2019-01-08 15:16 +0100
              Re: importare database mysql dentro un contenitore (docker) Alessandro Pellizzari <shuriken@amiran.it> - 2019-01-12 09:58 +0000
                Re: importare database mysql dentro un contenitore (docker) sky winter <sky@bo.bo> - 2019-01-12 19:23 +0100
                Re: importare database mysql dentro un contenitore (docker) Alessandro Pellizzari <shuriken@amiran.it> - 2019-01-12 19:50 +0000
                Re: importare database mysql dentro un contenitore (docker) sky winter <sky@bo.bo> - 2019-01-13 10:36 +0100

csiph-web