symfony 中没有通过学说连接数据库
我正在研究 symfony 教程 jobeet,并且在通过原则获得与 MySQL 数据库的数据库连接时遇到问题。开发环境:Mac OS X 和 XAMPP。
命令 php symfonydoctrine:build-schema
给出以下错误消息:
警告:PDO::__construct(): [2002] /Users/xx/projects/myproject/lib/ 中没有这样的文件或目录(尝试通过 unix:///var/mysql/mysql.sock 连接)供应商/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection.php 第 470 行
PDO 连接错误:SQLSTATE[HY000] [2002] 没有这样的文件或目录
database.yml中的数据库设置:
all:
doctrine:
class: sfDoctrineDatabase
param:
dsn: 'mysql:host=localhost;dbname=my_project_db'
username: root
password: root
MySQl正在运行。用户名和密码正确。数据库“my_project_db”存在。
有人能给我提示出了什么问题吗?
I'm working on the symfony tutorial jobeet and I have problems to get a database connection to the MySQL-database via doctrine. Development enviroment: Mac OS X and XAMPP.
The command php symfony doctrine:build-schema
gives me the following error message:
Warning: PDO::__construct(): [2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock) in /Users/xx/projects/myproject/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection.php on line 470
PDO Connection Error: SQLSTATE[HY000] [2002] No such file or directory
The database settings in the database.yml:
all:
doctrine:
class: sfDoctrineDatabase
param:
dsn: 'mysql:host=localhost;dbname=my_project_db'
username: root
password: root
MySQl is running. Username and password are correct. The database 'my_project_db' exists.
Could anybody give me a hint what's going wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
尝试在
/var/mysql
中创建一个指向mysql.sock
的符号链接:Try to create a symlink in
/var/mysql
to yourmysql.sock
:或者使用 MAMP
Or with MAMP
在 Mac OSX Lion 上:
On Mac OSX Lion:
我在我的苹果电脑上遇到了同样的问题,并执行了以下操作:
为我工作。
I had the same problem on my apple mac and did the following:
Worked for me.
这种情况也发生在我身上,我使用的是MAMP Pro。如果您使用 MAMP Pro,则值得检查主窗口。查看“MySQL”选项卡,然后看到“仅允许本地访问”复选框。如果已选中,则应取消选中它。最后,单击“应用”按钮。
This situation also happened to me and I use MAMP Pro. If you use MAMP Pro, its worth checking the main window. Look at "MySQL" tab, and then see "Allow local access only" checkbox. If it is checked, you should uncheck it. Finally, click, "Apply" button.