Symfony2 DB2 学说:无法创建数据库
Symfony2 DB2 doctrine: Could not create database
如果我想在 DB2 docrine 响应中创建我的数据库结构:
>php app/console doctrine:database:create
Could not create database "monng" for connection named default
Notice: Undefined index: dbname
但是从 DB(read/write 到 DB2)创建实体是可能的:
>php app/console doctrine:mapping:import AppBundle
Importing mapping information from "default" entity manager
> writing /var/www/html/structure/src/AppBundle/Resources/config/doctrine/Projects.orm.xml
还通过 CRUD 创建了前端,我没有问题 - 可以 write/edit/delete 项。
parameter.yml:
parameters:
database_host: 172.25.x.y
database_port: '60000'
database_name: structure
database_user: structure
database_password: xxxxxxx
database_driver: ibm_db2
config.yml:
...
# Doctrine Configuration
doctrine:
dbal:
driver: "%database_driver%"
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
...
你有什么想法吗?
doctrine/doctrine-bundle 1.6.2 Symfony DoctrineBundle
编辑
做了一些进一步的研究:
[_params:Doctrine\DBAL\Connection:private] => Array
(
[driver] => ibm_db2
[host] => 172.25.75.10
[port] => 60000
[user] => monng
[password] => monng
[charset] => UTF8
[driverOptions] => Array
(
)
[defaultTableOptions] => Array
(
)
)
您可以尝试删除 database_port 上的引号。否则数据库的用户结构可能无权创建?
解决方案似乎很简单:
对于 DB2-Connect
,只需使用 "doctrine:schema:create" 而不是 "doctrine:database:create"
如果我想在 DB2 docrine 响应中创建我的数据库结构:
>php app/console doctrine:database:create
Could not create database "monng" for connection named default
Notice: Undefined index: dbname
但是从 DB(read/write 到 DB2)创建实体是可能的:
>php app/console doctrine:mapping:import AppBundle
Importing mapping information from "default" entity manager
> writing /var/www/html/structure/src/AppBundle/Resources/config/doctrine/Projects.orm.xml
还通过 CRUD 创建了前端,我没有问题 - 可以 write/edit/delete 项。
parameter.yml:
parameters:
database_host: 172.25.x.y
database_port: '60000'
database_name: structure
database_user: structure
database_password: xxxxxxx
database_driver: ibm_db2
config.yml:
...
# Doctrine Configuration
doctrine:
dbal:
driver: "%database_driver%"
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
...
你有什么想法吗?
doctrine/doctrine-bundle 1.6.2 Symfony DoctrineBundle
编辑 做了一些进一步的研究:
[_params:Doctrine\DBAL\Connection:private] => Array
(
[driver] => ibm_db2
[host] => 172.25.75.10
[port] => 60000
[user] => monng
[password] => monng
[charset] => UTF8
[driverOptions] => Array
(
)
[defaultTableOptions] => Array
(
)
)
您可以尝试删除 database_port 上的引号。否则数据库的用户结构可能无权创建?
解决方案似乎很简单:
对于 DB2-Connect
,只需使用 "doctrine:schema:create" 而不是 "doctrine:database:create"