dongshang5862 2017-09-04 13:15 采纳率: 0%
浏览 74
已采纳

连接和创建数据库时出错

I am following the tutorial for Doctrine: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/tutorials/getting-started.html

I changed the bootstrap file to include my database to:

<?php
// bootstrap.php
use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;

require_once "vendor/autoload.php";

// Create a simple "default" Doctrine ORM configuration for Annotations
$isDevMode = false;
$paths = array(__DIR__."/src");
$config = Setup::createAnnotationMetadataConfiguration($paths, $isDevMode);
// or if you prefer yaml or XML
//$config = Setup::createXMLMetadataConfiguration(array(__DIR__."/config/xml"), $isDevMode);
//$config = Setup::createYAMLMetadataConfiguration(array(__DIR__."/config/yaml"), $isDevMode);

// database configuration parameters
$conn = array(
    'host' => 'http://192.*******',
      'port' => '3306',
      'user' => '********',
      'password' => '****',
      'dbname' => 'bugs',
      'charset' => 'UTF8',
    'driver' => 'pdo_mysql',

);

// obtaining the entity manager
$entityManager = EntityManager::create($conn, $config);

But get this message when I try to run:

vendor/bin/doctrine orm:schema-tool:create 

[Doctrine\DBAL\Exception\ConnectionException]                                
  An exception occurred in driver: SQLSTATE[HY000] [2002] php_network_getaddr  
  esses: getaddrinfo failed: Name or service not known                         



  [Doctrine\DBAL\Driver\PDOException]                                          
  SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name o  
  r service not known                                                          



  [PDOException]                                                               
  SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name o  
  r service not known                                                          



  [PDOException]                                                               
  PDO::__construct(): php_network_getaddresses: getaddrinfo failed: Name or s  
  ervice not known    

Thank you in advance

  • 写回答

1条回答 默认 最新

  • doulianglou0898 2017-09-04 13:20
    关注

    Host is supposed to be an ip address or a host name. You have included http in it which is a protocol. I suppose your host should be only 192.******* instead of http://192.*******.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗
  • ¥15 钢筋实图交点识别,机器视觉代码
  • ¥15 如何在Linux系统中,但是在window系统上idea里面可以正常运行?(相关搜索:jar包)
  • ¥50 400g qsfp 光模块iphy方案
  • ¥15 两块ADC0804用proteus仿真时,出现异常
  • ¥15 关于风控系统,如何去选择
  • ¥15 这款软件是什么?需要能满足我的需求
  • ¥15 SpringSecurityOauth2登陆前后request不一致