title: Cannot create database connection for Doctrine2 in Symfony2 with MAMP (Connection refused)
body: <p>I'm in the process of learning Symfony2 for a project that me and some friends are taking on, and am taking a tutorial where you make a blog in Symfony2: <a href="http://tutorial.symblog.co.uk/docs/doctrine-2-the-blog-model.html" rel="nofollow">http://tutorial.symblog.co.uk/docs/doctrine-2-the-blog-model.html</a></p>
  
  <p><strong>Problem</strong></p>
  
  <p>I can't seem to get Doctrine2 to work. I give the following instruction to the Terminal:</p>
  
  <pre><code>php app/console doctrine:database:create
  </code></pre>
  
  <p>And get the following error message:</p>
  
  <blockquote>
    <p>Could not create database for connection named <code>symfony</code>
    SQLSTATE[HY000] [2002] Connection refused</p>
  </blockquote>
  
  <p><strong>System info</strong></p>
  
  <p>I have a mac that runs Mountain lion and I use MAMP.</p>
  
  <p><strong>What I have done</strong></p>
  
  <p>I went to the config page (<code>http://localhost/NameOfProject/web/config.php</code>) and went to the place where you configure your database. There I put in the path, port, user, password, etc from the MAMP start page.</p>
  
  <p><strong>What I have tried</strong></p>
  
  <p>A blog I came across suggested to create a symbolic link to the the MAMP mysql socket with the following command:</p>
  
  <pre><code>sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock mysql.sock
  </code></pre>
  
  <p>This did not make the error go away for me.</p>
  
  <p><strong>Some of my files in symfony (if they are relevant)</strong></p>
  
  <p>From <code>app/config/config.yml</code>:</p>
  
  <pre><code>parameters:
      database_driver: pdo_mysql
      database_host: 127.0.0.1
      database_port: '8889'
      database_name: symfony
      database_user: root
      database_password: root
      mailer_transport: smtp
      mailer_host: 127.0.0.1
      mailer_user: null
      mailer_password: null
      locale: en
      secret: 0408312e2b9861c0c86dbb7488aceec4296054ec
      database_path: /Applications/MAMP/tmp/mysql/mysql.sock
  </code></pre>
  
  <p>From <code>app/config/parameters.yml</code>:</p>
  
  <pre><code>parameters:
      database_driver: pdo_mysql
      database_host: 127.0.0.1
      database_port: '8889'
      database_name: symfony
      database_user: root
      database_password: root
      mailer_transport: smtp
      mailer_host: 127.0.0.1
      mailer_user: null
      mailer_password: null
      locale: en
      secret: 0408312e2b9861c0c86dbb7488aceec4296054ec
      database_path: /Applications/MAMP/tmp/mysql/mysql.sock
  </code></pre>
  
  <p>The tutorial talks updating the database_* options in the parameters file located at <code>app/config/parameters.ini</code>. However, I don't have a <code>parameters.ini</code> file located in this folder! Only <code>parameters.yml</code>.</p>
  
  <p><strong>Edit: Solution:</strong></p>
  
  <p>I was using the wrong port number for MySql. When I used 3306 it worked.</p>