0
votes

After upgrading to a php 7.1 server I get a "connection refused error" Upgrading my localhost to php 7.2 results in a similar error. Below I have included the details of the localhost.

I am trying to use doctrine stand alone without Symfony or Lavarel. I use as MAC and currently Bitnami Mamp stack 7.2.0-0

I am able to access the database via phpyadmin (the credentials username/password are fine)

My PHP.ini file contains:

pdo_mysql.default_socket = "/Applications/mampstack-7.2.0-0/mysql/tmp/mysql.sock"

I have composer installed.

{
    "require": {
        "doctrine/orm": "2.5.*",
        "symfony/yaml": "2.*"
    },
    "autoload": {
        "psr-0": {"": "src/"}
    }
}

My bootstrap.php looks like: (I have tried both localhost and 127.0.0.1)

<?php

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

require_once "vendor/autoload.php";

$paths = array(__DIR__ . "/entities");

$dbParams = array(
    'driver' => 'pdo_mysql', 
    'host' => '127.0.0.1', // localhost
    'user' => 'root',
    'password' => '123456',
    'dbname' => 'doctrine_test'
);

$isDevMode = TRUE;
$config = Setup::createAnnotationMetadataConfiguration($paths, $isDevMode);


$entityManager = EntityManager::create($dbParams, $config);

I have a basic config/cli-config.php file

require_once "bootstrap.php";

return \Doctrine\ORM\Tools\Console\ConsoleRunner::createHelperSet($entityManager);

However I am still stuck with a connection error: An exception occurred in driver: SQLSTATE[HY000] [2002] Connection refused

1

1 Answers

1
votes

After hours and hours adding another mysql user turned out to be the solution. For some reason the root user isn't allowed? It solved the issue both on the localhost and production environment.