久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <legend id='WcKgI'><style id='WcKgI'><dir id='WcKgI'><q id='WcKgI'></q></dir></style></legend>
      <bdo id='WcKgI'></bdo><ul id='WcKgI'></ul>
    <tfoot id='WcKgI'></tfoot>

    <small id='WcKgI'></small><noframes id='WcKgI'>

    <i id='WcKgI'><tr id='WcKgI'><dt id='WcKgI'><q id='WcKgI'><span id='WcKgI'><b id='WcKgI'><form id='WcKgI'><ins id='WcKgI'></ins><ul id='WcKgI'></ul><sub id='WcKgI'></sub></form><legend id='WcKgI'></legend><bdo id='WcKgI'><pre id='WcKgI'><center id='WcKgI'></center></pre></bdo></b><th id='WcKgI'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='WcKgI'><tfoot id='WcKgI'></tfoot><dl id='WcKgI'><fieldset id='WcKgI'></fieldset></dl></div>

      1. 使用 Docker 我得到錯誤:“SQLSTATE[HY000] [2002] No su

        Using Docker I get the error: quot;SQLSTATE[HY000] [2002] No such file or directoryquot;(使用 Docker 我得到錯誤:“SQLSTATE[HY000] [2002] No such file or directory)
      2. <legend id='n0d3c'><style id='n0d3c'><dir id='n0d3c'><q id='n0d3c'></q></dir></style></legend>
        • <i id='n0d3c'><tr id='n0d3c'><dt id='n0d3c'><q id='n0d3c'><span id='n0d3c'><b id='n0d3c'><form id='n0d3c'><ins id='n0d3c'></ins><ul id='n0d3c'></ul><sub id='n0d3c'></sub></form><legend id='n0d3c'></legend><bdo id='n0d3c'><pre id='n0d3c'><center id='n0d3c'></center></pre></bdo></b><th id='n0d3c'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='n0d3c'><tfoot id='n0d3c'></tfoot><dl id='n0d3c'><fieldset id='n0d3c'></fieldset></dl></div>
        • <small id='n0d3c'></small><noframes id='n0d3c'>

            <tfoot id='n0d3c'></tfoot>

                <tbody id='n0d3c'></tbody>
                <bdo id='n0d3c'></bdo><ul id='n0d3c'></ul>

                  本文介紹了使用 Docker 我得到錯誤:“SQLSTATE[HY000] [2002] No such file or directory"的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  我正在使用 Docker 創(chuàng)建一個容器,以在 Mac 上測試基于 PHP 和 MySQL 構(gòu)建的 Web 應(yīng)用程序.我的 PHP 應(yīng)用程序是使用 Fat-Free Framework 構(gòu)建的,用于 MVC 和路由.我有兩個 Dockerfile,一個用于 MySQL,一個用于 PHP.我已經(jīng)成功地使用了測試 Docker 應(yīng)用程序,所以我相信我的圖像安裝正確.

                  I'm using Docker to create a container to test my web app built on PHP and MySQL on my Mac. My PHP app is built using Fat-Free Framework for MVC and routing. I have two Dockerfiles, one for MySQL and one for PHP. I've used test Docker applications successfully, so I believe my images are installed correctly.

                  錯誤的主要部分:

                  Internal Server Error
                  
                  SQLSTATE[HY000] [2002] No such file or directory
                  
                  [fatfree/lib/DB/SQL.php:466] PDO->__construct('mysql:host=127.0.0.1;port=3306;dbname=robohome','root','password',array(1002=>'SET NAMES utf8;'))
                  [fatfree/app/Controllers/Controller.php:24] DBSQL->__construct('mysql:host=127.0.0.1;port=3306;dbname=robohome','root','password')
                  

                  注意,如果我使用 127.0.0.1 而不是 localhost 進行連接,我會收到一個稍微不同的錯誤:SQLSTATE[HY000] [2002] Connection denied

                  Note, if I connect using 127.0.0.1 instead of localhost I get a slightly different error that says: SQLSTATE[HY000] [2002] Connection refused

                  我的 PHP Dockerfile:

                  My PHP Dockerfile:

                  FROM php:5.6-apache
                  
                  RUN docker-php-ext-install mysqli pdo pdo_mysql
                  RUN a2enmod rewrite
                  

                  我的 MySQL Dockerfile:

                  My MySQL Dockerfile:

                  FROM mysql:5.7
                  
                  ENV MYSQL_ROOT_PASSWORD password
                  ENV MYSQL_DATABASE robohome
                  
                  COPY ./schema.sql /docker-entrypoint-initdb.d/
                  

                  我的 Controller.php 文件,其中錯誤提到了第 24 行:

                  My Controller.php file where the error mentions line 24:

                  <?php
                  
                  namespace Controllers;
                  
                  class Controller
                  {
                      protected $f3;
                      protected $db;
                  
                      public function __construct()
                      {
                          $f3 = Base::instance();
                          $this->f3 = $f3;
                  
                          $mysqlServerName = $f3->get("MYSQL_SERVERNAME");
                          $mysqlDatabseName = $f3->get("MYSQL_DBNAME");
                  
                          //$container = DIContainerBuilder::buildDevContainer(); <-Not used currently
                  
                          //Below is line 24 referred to in the error
                          $db = new DBSQL(
                              "mysql:host={$mysqlServerName};port=3306;dbname={$mysqlDatabseName}",
                              $f3->get("MYSQL_USERNAME"),
                              $f3->get("MYSQL_PASSWORD")
                          );
                  
                          $this->db = $db;
                      }
                  

                  那些 MYSQL_* 值是從 .ini 文件中提取的:

                  Those MYSQL_* values are pulled from an .ini file:

                  MYSQL_SERVERNAME = "localhost" <-This is what I've tried changing to 127.0.0.1
                  MYSQL_USERNAME = "root"
                  MYSQL_PASSWORD = "password"
                  MYSQL_DBNAME = "robohome"
                  

                  我的 Docker 撰寫文件:

                  My Docker compose file:

                  version: '2'
                  
                  services:
                    web:
                      build: ./docker/php
                      ports:
                        - 80:80
                      volumes:
                        - .:/var/www/html/
                      links:
                        - db
                    db:
                      build: ./docker/mysql
                      ports:
                        - 3306
                  

                  我通過執(zhí)行 docker-compose up --build -d 來運行它.然后我可以從 docker ps 得到的輸出是:

                  I run this by doing docker-compose up --build -d. The output I can then get from docker ps is:

                  CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                     NAMES
                  f35066a16586        robohomeweb_mysql   "docker-entrypoint.sh"   3 minutes ago       Up 2 seconds        0.0.0.0:32777->3306/tcp   robohomeweb_mysql_1
                  86d34eb34583        robohomeweb_php     "apache2-foreground"     3 minutes ago       Up 2 seconds        0.0.0.0:80->80/tcp        robohomeweb_php_1
                  

                  如果我改為在前臺運行,則會得到以下輸出:

                  If I run in the foreground instead, I get the following output:

                  Building php
                  Step 1 : FROM php:5.6-apache
                   ---> 8f9b7e57129a
                  Step 2 : RUN docker-php-ext-install mysqli pdo pdo_mysql
                   ---> Using cache
                   ---> fadd8f9e7207
                  Step 3 : RUN a2enmod rewrite
                   ---> Using cache
                   ---> 9dfed7fdc60f
                  Successfully built 9dfed7fdc60f
                  Building mysql
                  Step 1 : FROM mysql:5.7
                   ---> eda6a4884645
                  Step 2 : ENV MYSQL_ROOT_PASSWORD password
                   ---> Using cache
                   ---> 759895ac5772
                  Step 3 : ENV MYSQL_DATABASE robohome
                   ---> Using cache
                   ---> e926c5ecc088
                  Step 4 : COPY ./schema.sql /docker-entrypoint-initdb.d/
                   ---> Using cache
                   ---> cf5d00aa8020
                  Successfully built cf5d00aa8020
                  Starting robohomeweb_php_1
                  Starting robohomeweb_mysql_1
                  Attaching to robohomeweb_mysql_1, robohomeweb_php_1
                  php_1    | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.18.0.3. Set the 'ServerName' directive globally to suppress this message
                  php_1    | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.18.0.3. Set the 'ServerName' directive globally to suppress this message
                  php_1    | [Sun Oct 16 20:21:17.944575 2016] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.10 (Debian) PHP/5.6.26 configured -- resuming normal operations
                  php_1    | [Sun Oct 16 20:21:17.946919 2016] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
                  mysql_1  | 2016-10-16T20:21:18.036272Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
                  mysql_1  | 2016-10-16T20:21:18.038330Z 0 [Note] mysqld (mysqld 5.7.16) starting as process 1 ...
                  mysql_1  | 2016-10-16T20:21:18.043331Z 0 [Note] InnoDB: PUNCH HOLE support available
                  mysql_1  | 2016-10-16T20:21:18.043603Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
                  mysql_1  | 2016-10-16T20:21:18.043951Z 0 [Note] InnoDB: Uses event mutexes
                  mysql_1  | 2016-10-16T20:21:18.044077Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
                  mysql_1  | 2016-10-16T20:21:18.044260Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
                  mysql_1  | 2016-10-16T20:21:18.044414Z 0 [Note] InnoDB: Using Linux native AIO
                  mysql_1  | 2016-10-16T20:21:18.045150Z 0 [Note] InnoDB: Number of pools: 1
                  mysql_1  | 2016-10-16T20:21:18.045620Z 0 [Note] InnoDB: Using CPU crc32 instructions
                  mysql_1  | 2016-10-16T20:21:18.047629Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
                  mysql_1  | 2016-10-16T20:21:18.057705Z 0 [Note] InnoDB: Completed initialization of buffer pool
                  mysql_1  | 2016-10-16T20:21:18.059988Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
                  mysql_1  | 2016-10-16T20:21:18.074670Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
                  mysql_1  | 2016-10-16T20:21:18.101209Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
                  mysql_1  | 2016-10-16T20:21:18.101433Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
                  mysql_1  | 2016-10-16T20:21:18.354806Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
                  mysql_1  | 2016-10-16T20:21:18.356928Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
                  mysql_1  | 2016-10-16T20:21:18.357158Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
                  mysql_1  | 2016-10-16T20:21:18.358049Z 0 [Note] InnoDB: Waiting for purge to start
                  mysql_1  | 2016-10-16T20:21:18.412987Z 0 [Note] InnoDB: 5.7.16 started; log sequence number 12179647
                  mysql_1  | 2016-10-16T20:21:18.414470Z 0 [Note] Plugin 'FEDERATED' is disabled.
                  mysql_1  | 2016-10-16T20:21:18.421833Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
                  mysql_1  | 2016-10-16T20:21:18.424144Z 0 [Note] InnoDB: Buffer pool(s) load completed at 161016 20:21:18
                  mysql_1  | 2016-10-16T20:21:18.425607Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key
                  mysql_1  | 2016-10-16T20:21:18.427018Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
                  mysql_1  | 2016-10-16T20:21:18.427581Z 0 [Note] IPv6 is available.
                  mysql_1  | 2016-10-16T20:21:18.427749Z 0 [Note]   - '::' resolves to '::';
                  mysql_1  | 2016-10-16T20:21:18.428019Z 0 [Note] Server socket created on IP: '::'.
                  mysql_1  | 2016-10-16T20:21:18.456023Z 0 [Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.
                  mysql_1  | 2016-10-16T20:21:18.456354Z 0 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.
                  mysql_1  | 2016-10-16T20:21:18.480237Z 0 [Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.
                  mysql_1  | 2016-10-16T20:21:18.488758Z 0 [Note] Event Scheduler: Loaded 0 events
                  mysql_1  | 2016-10-16T20:21:18.490880Z 0 [Note] mysqld: ready for connections.
                  mysql_1  | Version: '5.7.16'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server (GPL)
                  

                  根據(jù)我的研究,我嘗試使用 localhost127.0.0.1 進行連接,因為它們在技術(shù)上的處理方式不同.這也可能與嘗試通過套接字而不是 TCP 進行對話有關(guān).理想情況下,我想要一個可以融入 Dockerfile 的解決方案,這樣我就不必擔(dān)心記住命令或我是如何做某事的.

                  From my research, I've tried connecting using both localhost and 127.0.0.1 since they're technically treated differently. It could also be something related to trying to talk via sockets instead of TCP. Ideally I would like a solution that I can bake into my Dockerfiles so I don't have to worry about remembering commands or how I did something.

                  推薦答案

                  正如有人在評論中指出的那樣,您提供的 docker-compose 文件與您的問題非常相關(guān).

                  As someone pointed out in the comments, the docker-compose file you provided is very relevant to your question.

                  docker 中 links 的文檔-撰寫文件說

                  The documentation for links in docker-compose files says

                  鏈接服務(wù)的容器將可以通過與別名相同的主機名訪問,如果未指定別名,則可以訪問服務(wù)名稱.

                  Containers for the linked service will be reachable at a hostname identical to the alias, or the service name if no alias was specified.

                  在您的情況下,數(shù)據(jù)庫容器名為 db,因此從 PHP 容器解析 db 主機應(yīng)該將您指向 MySQL 容器.將配置文件中的 localhost 替換為 db 應(yīng)該允許 PHP 容器連接到 MySQL.

                  In your case, the database container is named db, so resolving db host from the PHP container should point you at the MySQL container. Replacing localhost with db in your config file should allow the PHP container to connect to MySQL.

                  這篇關(guān)于使用 Docker 我得到錯誤:“SQLSTATE[HY000] [2002] No such file or directory"的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  Deadlock exception code for PHP, MySQL PDOException?(PHP、MySQL PDOException 的死鎖異常代碼?)
                  PHP PDO MySQL scrollable cursor doesn#39;t work(PHP PDO MySQL 可滾動游標(biāo)不起作用)
                  PHP PDO ODBC connection(PHP PDO ODBC 連接)
                  Using PDO::FETCH_CLASS with Magic Methods(使用 PDO::FETCH_CLASS 和魔術(shù)方法)
                  php pdo get only one value from mysql; value that equals to variable(php pdo 只從 mysql 獲取一個值;等于變量的值)
                  MSSQL PDO could not find driver(MSSQL PDO 找不到驅(qū)動程序)
                    <tbody id='gl6NF'></tbody>
                        • <bdo id='gl6NF'></bdo><ul id='gl6NF'></ul>
                          <tfoot id='gl6NF'></tfoot><legend id='gl6NF'><style id='gl6NF'><dir id='gl6NF'><q id='gl6NF'></q></dir></style></legend>

                            <small id='gl6NF'></small><noframes id='gl6NF'>

                            <i id='gl6NF'><tr id='gl6NF'><dt id='gl6NF'><q id='gl6NF'><span id='gl6NF'><b id='gl6NF'><form id='gl6NF'><ins id='gl6NF'></ins><ul id='gl6NF'></ul><sub id='gl6NF'></sub></form><legend id='gl6NF'></legend><bdo id='gl6NF'><pre id='gl6NF'><center id='gl6NF'></center></pre></bdo></b><th id='gl6NF'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='gl6NF'><tfoot id='gl6NF'></tfoot><dl id='gl6NF'><fieldset id='gl6NF'></fieldset></dl></div>

                            主站蜘蛛池模板: 亚洲视频在线一区 | 99re国产视频| 在线播放中文字幕 | 99看片网| 视频在线观看一区二区 | 黑人性hd | 亚洲一区二区精品视频 | 国产视频1区2区 | 91麻豆精品国产91久久久久久 | 国产精品一区在线观看 | 91久久精品日日躁夜夜躁国产 | 成人免费视频网站在线看 | 中文字幕一区二区三区乱码在线 | h视频免费在线观看 | 91黄在线观看 | 欧美成人综合 | 欧美一级三级在线观看 | 中文字幕精品一区 | 黄色网址av| 一级黄色毛片a | 91精品国产91久久久久久吃药 | 又爽又黄axxx片免费观看 | 亚洲精品国产a久久久久久 午夜影院网站 | 日韩精品视频中文字幕 | 欧美视频成人 | 国产成人精品一区二区 | 九九九色| 亚洲国产aⅴ成人精品无吗 亚洲精品久久久一区二区三区 | 日韩视频一区二区 | 国产成人午夜高潮毛片 | 成人免费在线观看 | 亚洲一区在线日韩在线深爱 | 久久久www成人免费精品 | 97色在线视频 | 国产美女福利在线观看 | 男人天堂免费在线 | 国产午夜一级 | 欧美视频二区 | 日韩欧美高清 | 午夜免费看视频 | 国产视频精品在线观看 |