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 本地测试网站127.0.0.1 已拒绝连接,如何解决?(标签-ubuntu)
  • ¥50 Qt在release捕获异常并跟踪堆栈(有Demo,跑一下环境再回答)
  • ¥30 python,LLM 文本提炼
  • ¥15 关于将inet引入的相关问题
  • ¥15 关于一个倒计时的操作和显示设计
  • ¥15 提问STK的问题,哪位航天领域的同学会啊
  • ¥15 苹果系统的mac m1芯片的笔记本使用ce修改器使用不了
  • ¥15 单相逆变的电压电流双闭环中进行低通滤波PID算法改进
  • ¥15 关于#java#的问题,请各位专家解答!
  • ¥15 如何卸载arcgis 10.1 data reviewer for desktop