问题描述
我不熟悉Symfony,并开始做一些教程以完成一些工作.我正在使用Linux Mint 18机器和标准的Symfony3-project.
I am new to Symfony and started doing some tutorials in order to get some things done. I am working on a Linux Mint 18 machine and a standard Symfony3-project.
我想创建一个简单的数据库来使用它,但是遇到一个错误,找不到适合的解决方案.
I'd like to create a simple database to play around with it, but I am encountering an error I can't find the right solution for.
我的parameters.yml文件如下:
My parameters.yml file looks like this:
parameters:
database_host: localhost
database_port: null
database_name: symfony
database_user: root
database_password: null
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: null
mailer_password: null
secret: (not relevant)
我的Genus.php文件如下所示:
My Genus.php file looks like this:
namespace AppBundle\Genus;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="genus")
*/
class Genus
{
/**
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string")
*/
private $name;
}
当我执行命令 dpkg -l php * mysql 时,我得到以下结果:
When I execute the command dpkg -l php*mysql I get the following result:
dpkg -l php*mysql
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-=================-=============-=============-============================
un php-pdo-mysql <none> <none> (no description available)
ii php7.0-mysql 7.0.8-0ubuntu amd64 MySQL module for PHP
un php7.0-pdo-mysql <none> <none> (no description available)
当我尝试使用命令提示符使用创建本地数据库时
When I try to create a local database using the command prompt using
XXX@XXX-pc ~/PhpstormProjects/test_symfony $ php bin/console doctrine:database:create
这就是我得到的:
我遇到了许多其他话题,但是找不到正确的答案.谁能告诉我我在这里想念的东西吗?任何帮助都非常感激:)
I've came across many other topics but wasn't able to find the right answer. Could anyone tell me what I am missing here? Any help is much appreciated :)
推荐答案
在我的情况下,我仅更改了localhost-> 127.0.0.1即可正常工作!
In my case, I only changed localhost->127.0.0.1 and it worked!
这篇关于Symfony3-SQLSTATE [HY000] [2002]没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!