Doctrine 2命令行工具; MAMP和mysql.sock [英] Doctrine 2 command line tool; MAMP and mysql.sock

查看:262
本文介绍了Doctrine 2命令行工具; MAMP和mysql.sock的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从疯狂不准确抓取了CI2 / Doctrine2。我想开始使用它,但在我真正使用它之前,我想确保一切正常。但是,当我尝试命令行工具,我遇到以下错误:

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]

我在一个干净安装的MAMP Pro 2.0.1上运行这个程序;我不知道该怎么做来解决这个错误..我真的不知道MySQL的内部(背景)工作。有人可以为我清除这一点吗?非常感谢。

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.

更新:

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


推荐答案

MAMP使用它自己的mysql套接字而CLi使用/var/mysql/mysql.sock中的默认值。
这可能意味着你运行的是错误的PHP版本(不是MAMP,而是默认的MAC OS X)。没有什么大不了,因为它也可以处理你的Doctrine命令行问题。
所以你有几个选项:

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. 尝试使用MAMP PHP版本启动CLi工具,您的MAC OS X php版本的路径作为前缀

  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:创建

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

只是设置一个链接从/var/mysql/mysql.sock到实际的Socket文件应该在/ Applications / MAMP // tmp / mysql / mysql.sock
所以你在你的MAMP运行一个类型时你去终端(你会被要求输入一个密码):

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

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

查找每次出现的/ Applications / MAMP // tmp / mysql / mysql.sock在任何您的MAMP配置文件,并将其更改为/var/mysql/mysql.sock,因此您实际上使用MySQL Socket的默认地址。虽然,我从来没有测试过这是否有效。

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.

这篇关于Doctrine 2命令行工具; MAMP和mysql.sock的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆