[英]Error when trying to create doctrine database with phpMyAdmin
I'm a fresh junior php developer and I'm building my first Symfony project.我是一名初级 php 开发人员,正在构建我的第一个 Symfony 项目。
When I used the command : php bin/console doctrine:database:create
I get these errors :当我使用命令 :
php bin/console doctrine:database:create
我收到以下错误:
In AbstractMySQLDriver.php line 93:
在 AbstractMySQLDriver.php 第 93 行中:
An exception occurred in driver: SQLSTATE[HY000] [2002] No such file or directory驱动程序发生异常:SQLSTATE[HY000] [2002] No such file or directory
In PDOConnection.php line 31:
在 PDOConnection.php 第 31 行:
SQLSTATE[HY000] [2002] No such file or directorySQLSTATE[HY000] [2002] 没有那个文件或目录
In PDOConnection.php line 27:
在 PDOConnection.php 第 27 行:
SQLSTATE[HY000] [2002] No such file or directory*SQLSTATE[HY000] [2002] 没有那个文件或目录*
I'm actually using MAMP with default config "db_user" and "db_password" so I edited the .env file with this following code : DATABASE_URL=mysql://root:root@localhost:8889/mydbname
我实际上使用带有默认配置“db_user”和“db_password”的 MAMP,所以我使用以下代码编辑了 .env 文件:
DATABASE_URL=mysql://root:root@localhost:8889/mydbname
I know there is something wrong with my host or port, I saw on other topics that some users using MAMP keep Symfony default values for host and port : DATABASE_URL=mysql://root:root@127.0.0.1:3306/mydbname
我知道我的主机或端口有问题,我在其他主题上看到一些使用 MAMP 的用户保留主机和端口的 Symfony 默认值:
DATABASE_URL=mysql://root:root@127.0.0.1:3306/mydbname
Thanks for reading me and trying to help me.感谢您阅读我并尝试帮助我。
I did more searches and some people are saying that localhost syntax is depreciated and prefer using : 127.0.0.1
instead of localhost
.我做了更多的搜索,有些人说 localhost 语法已贬值,并且更喜欢使用 :
127.0.0.1
而不是localhost
。
In my case I checked and used Mamp config 'Connect using an UNIX socket'在我的情况下,我检查并使用了 Mamp 配置“使用 UNIX 套接字连接”
So it's now working with :所以它现在与:
DATABASE_URL=mysql://root:root@127.0.0.1:8889/mydbname
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.