我在最新的Ubuntu上的bitnami LAMPStack 7.4.6-1
上运行MySQL
数据库。当我以root用户身份运行此命令时:
3307 port
我看到的错误是:
root@ubuntu:/opt/lampstack-7.4.6-1/apache2/htdocs/sfcourse# php bin/console doctrine:database:create
。env文件[error] Error thrown while running command "doctrine:database:create". Message: "An exception occurred in driver: SQLSTATE[HY000] [2002] Connection refused"
In AbstractMySQLDriver.php line 93:
An exception occurred in driver: SQLSTATE[HY000] [2002] Connection refused
In PDOConnection.php line 31:
SQLSTATE[HY000] [2002] Connection refused
In PDOConnection.php line 27:
SQLSTATE[HY000] [2002] Connection refused
doctrine.yaml文件:
DATABASE_URL=mysql://root:000000@localhost:3307/sfcourse
googleed,但大多数建议是将127.0.0.1设为本地主机
在您的doctrine.yaml文件中,删除这些行
doctrine:
parameters:
env(DATABASE_URL): ''
dbal:
driver: 'pdo_mysql'
server_version: '5.7'
charset: utf8mb4
default_table_options:
charset: utf8mb4
collate: utf8mb4_unicode_ci
url: '%env(resolve:DATABASE_URL)%'
根据当前的 parameters:
env(DATABASE_URL): ''
,在doctrine.yaml文件中没有symonfy documentation for doctrine。
parameters
使我有些头疼。我用这条线修复了它
server_version
查找服务器版本server_version: 5.7.9
通过控制台连接到数据库,它将立即向您指出版本
source
或其他
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.0.27-standard MySQL Community Edition - Standard (GPL)