2

I grabbed the CI2/Doctrine2 from Wildly Inaccurate. I'm trying to start using it, but before I'm actually getting to work with it, I wanted to make sure everything works. However, when I try the command line tool, I run into the following error:

$ ./doctrine orm:schema-tool:create

ATTENTION: This operation should not be executed in a production environment.

Creating database schema...

Warning: PDO::__construct(): [2002] Socket operation on non-socket (trying to connect via unix:///var/mysql/mysql.sock) in /Users/joris/Desktop/ci2_starter/application/libraries/Doctrine/DBAL/Driver/PDOConnection.php on line 36



  [PDOException]                                         
  SQLSTATE[HY000] [2002] Socket operation on non-socket  



orm:schema-tool:create [--dump-sql]

I'm running this on a cleanly installed MAMP Pro 2.0.1; I'm not really sure what to do to fix this error.. I'm not really knowledgeable on the inner (background) workings of MySQL. Could someone clear this up for me? Thanks a lot.

Update:

MacBook-Pro-van-Joris-Ooms:~ joris$ sudo find / -name 'mysql.sock'
Password:
/Applications/MAMP/tmp/mysql/mysql.sock
find: /dev/fd/3: Not a directory
find: /dev/fd/4: Not a directory
/private/var/mysql/mysql.sock
/private/var/mysql/mysql.sock/mysql.sock
Joris Ooms
  • 11,880
  • 17
  • 67
  • 124

1 Answers1

4

MAMP does use it's own mysql socket while the CLi uses the default one in /var/mysql/mysql.sock. This could mean you are running the wrong PHP version (not the MAMP one but the default MAC OS X one). Not a big deal since it can deal with your Doctrine Command Line Issues as well. So you do have several options:

  1. try using the MAMP php version to start the CLi tool by putting the Path to your MAC OS X php version as a prefix i.e.

    /Applications/MAMP/bin/php5.3/bin/php ./doctrine orm:schema-tool:create

  2. just set up a link from /var/mysql/mysql.sock to the actual Socket file which should be in /Applications/MAMP//tmp/mysql/mysql.sock So you go to the terminal while your MAMP is running an type (You will be asked to type in a password):

    sudo ln -s /Applications/MAMP//tmp/mysql/mysql.sock /var/mysql/mysql.sock

  3. Find every occurrence of "/Applications/MAMP//tmp/mysql/mysql.sock" in any of your MAMP config files and change it to be /var/mysql/mysql.sock so you actually do use the default address for MySQL Socket. Though, i have never tested if this does work.

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Andresch Serj
  • 35,217
  • 15
  • 59
  • 101
  • Trying the first option, I get this: ln: /var/mysql/mysql.sock/mysql.sock: File exists. Thanks for the reply, btw. – Joris Ooms Sep 27 '11 at 11:56
  • @cabaret: Could you try to find all the mysql.sock files on your system? Use this line: sudo find / -name 'mysql.sock' – Andresch Serj Sep 27 '11 at 11:57
  • I updated my original post with the result, as it's a bit much to put in a comment. – Joris Ooms Sep 27 '11 at 12:08
  • 1
    The first option with the prefix worked.. However, isn't there an easier way to fix this? I gave you the bounty and accepted the answer though, because only one hour left and well, it works, even though it's a lot to type ;D – Joris Ooms Sep 27 '11 at 12:15
  • @cabaret: You could ty and your MAMPs php to the default folder where the MAC php is located. – Andresch Serj Sep 27 '11 at 15:27
  • 1
    The second option worked for me - thanks! The only tweak was the location of my /var... my command was: sudo ln -s /applications/mamp//tmp/mysql/mysql.sock /usr/local/var/mysql/mysql.sock – ryankeairns Jul 13 '12 at 12:26
  • 2
    Thanks, for me the full command was /Applications/MAMP/bin/php/php5.4.19/bin/php vendor/bin/doctrine-module orm:schema-tool:create – azz0r Oct 16 '14 at 14:45