我无法在symfony 1.0中连接MySQL数据库

时间:2012-03-04 11:26:20

标签: php database symfony1 mamp propel

我使用symfony1.0.22。在本地主机上,在MAMP上。 用askeet学习,我无法动弹......

我无法连接mySQL DB ... 它说“没有这样的档案或指令”。 我无法理解它在说什么!

日志在下面。请告诉我我能做什么......

>     symfony propel-insert-sql
>     >> schema    converting "/Applications/MAMP/..._fail/config/schema.yml" to XML
>     >> schema    putting /Applications/MAMP/htdo...ail/config/generated-schema.xml Buildfile:
> /Applications/MAMP/bin/php5/lib/php/symfony/vendor/propel-generator/build.xml
> [resolvepath] Resolved /Applications/MAMP/htdocs/hatch/sf_fail/config
> to /Applications/MAMP/htdocs/hatch/sf_fail/config
>     
>     propel-project-builder > check-project-or-dir-set:
>     
>     propel-project-builder > check-project-set:
>     
>     propel-project-builder > set-project-dir:
>     
>     propel-project-builder > check-buildprops-exists:
>     
>     propel-project-builder > check-buildprops-for-propel-gen:
>     
>     propel-project-builder > check-buildprops:
>     
>     propel-project-builder > configure:
>          [echo] Loading project-specific props from /Applications/MAMP/htdocs/hatch/sf_fail/config/propel.ini  [property]
> Loading /Applications/MAMP/htdocs/hatch/sf_fail/config/propel.ini
>     
>     propel-project-builder > insert-sql:
>         [phing] Calling Buildfile '/Applications/MAMP/bin/php5/lib/php/symfony/vendor/propel-generator/build-propel.xml'
> with target 'insert-sql'  [property] Loading
> /Applications/MAMP/bin/php5/lib/php/symfony/vendor/propel-generator/./default.properties
>     
>     propel > insert-sql: [propel-sql-exec] Executing statements in file:
> /Applications/MAMP/htdocs/hatch/sf_fail/data/sql/lib.model.schema.sql
> [propel-sql-exec] Our new url -> mysql://root:root@localhost/iii
> Execution of target "insert-sql" failed for the following reason:
> /Applications/MAMP/bin/php5/lib/php/symfony/vendor/propel-generator/build-propel.xml:296:1:
> [wrapped: connect failed [Native Error: No such file or directory]
> [User Info: Array]]
>         [phing] /Applications/MAMP/bin/php5/lib/php/symfony/vendor/propel-generator/build-propel.xml:296:1:
> [wrapped: connect failed [Native Error: No such file or directory]
> [User Info: Array]]
>     
>     BUILD FINISHED
>     
>     Total time: 0.3183 seconds
>     >> file-     /Applications/MAMP/htdocs/hatch...ail/config/generated-schema.xml

P.S。和propel.ini在下面。

>         propel.targetPackage       = lib.model
>         propel.packageObjectModel  = true
>         propel.project             = sf_fail
>         propel.database            = mysql
>         #propel.database.createUrl  = mysql://root:root@localhost/
>         propel.database.url        = mysql://root:root@localhost/sf_fail
>         
>         propel.addGenericAccessors = true
>         propel.addGenericMutators  = true
>         propel.addTimeStamp        = false
>         
>         propel.schema.validate     = false
>         propel.mysql.tableType = InnoDB
>         
>         ; directories
>         propel.home                    = .
>         propel.output.dir              = /var/www/symfony/sf_fail
>         propel.schema.dir              = ${propel.output.dir}/config
>         propel.conf.dir                = ${propel.output.dir}/config
>         propel.phpconf.dir             = ${propel.output.dir}/config
>         propel.sql.dir                 = ${propel.output.dir}/data/sql
>         propel.runtime.conf.file       = runtime-conf.xml
>         propel.php.dir                 = ${propel.output.dir}
>         propel.default.schema.basename = schema
>         propel.datadump.mapper.from    = *schema.xml
>         propel.datadump.mapper.to      = *data.xml
>         
>         ; builder settings
>         propel.builder.peer.class              = addon.propel.builder.SfPeerBuilder
>         propel.builder.object.class            = addon.propel.builder.SfObjectBuilder
>         
>         propel.builder.objectstub.class        = addon.propel.builder.SfExtensionObjectBuilder
>         propel.builder.peerstub.class          = addon.propel.builder.SfExtensionPeerBuilder
>         propel.builder.objectmultiextend.class = addon.propel.builder.SfMultiExtendObjectBuilder
>         propel.builder.mapbuilder.class        = addon.propel.builder.SfMapBuilderBuilder
>         propel.builder.interface.class         = propel.engine.builder.om.php5.PHP5InterfaceBuilder
>         propel.builder.node.class              = propel.engine.builder.om.php5.PHP5NodeBuilder
>         propel.builder.nodepeer.class          = propel.engine.builder.om.php5.PHP5NodePeerBuilder
>         propel.builder.nodestub.class          = propel.engine.builder.om.php5.PHP5ExtensionNodeBuilder
>         propel.builder.nodepeerstub.class      = propel.engine.builder.om.php5.PHP5ExtensionNodePeerBuilder
>         
>         propel.builder.addIncludes = false
>         propel.builder.addComments = false
>         
>         propel.builder.addBehaviors = false

在遇到此问题之前我做了什么

在/ Applications / MAMP / bin / php5 / lib / php / by pear中安装symfony1.0.22

$ sudo ln -s /Applications/MAMP/bin/php5/bin/pear /usr/bin/pear
$ pear upgrade PEAR 
$ pear channel-discover pear.symfony-project.com
$ pear install symfony-1.0.22
$ sudo ln -s -f /Applications/MAMP/bin/php5/bin/symfony /usr/bin/symfony

我在/ Application / MAMP中将dir命名为'sf_fail'

$cd /Application/MAMP/sf_fail
$symfony init-project sf_fail
$symfony init-app frontend

接下来,我编辑shema.yml,database.yml,propel.ini来创建DB。我用MAMP的phpMyAdmin创建了DB,名为'sf_fail'。

$symfony propel-build-model
$symfony propel-build-sql

我认为,在命令之前没有问题。

$symfony propel-insert-sql
这不能动......呃...... 我刚刚添加了“propel-build-all”的结果,以获取更多信息。

>         symfony propel-build-all
>         >> schema    converting "/Applications/MAMP/..._fail/config/schema.yml" to XML
>         >> schema    putting /Applications/MAMP/htdo...ail/config/generated-schema.xml
>         Buildfile: /Applications/MAMP/bin/php5/lib/php/symfony/vendor/propel-generator/build.xml
>         [resolvepath] Resolved /Applications/MAMP/htdocs/hatch/sf_fail/config to
> /Applications/MAMP/htdocs/hatch/sf_fail/config
>         
>         propel-project-builder > check-project-or-dir-set:
>         
>         propel-project-builder > check-project-set:
>         
>         propel-project-builder > set-project-dir:
>         
>         propel-project-builder > check-buildprops-exists:
>         
>         propel-project-builder > check-buildprops-for-propel-gen:
>         
>         propel-project-builder > check-buildprops:
>         
>         propel-project-builder > configure:
>              [echo] Loading project-specific props from /Applications/MAMP/htdocs/hatch/sf_fail/config/propel.ini
>          [property] Loading /Applications/MAMP/htdocs/hatch/sf_fail/config/propel.ini
>         
>         propel-project-builder > om:
>             [phing] Calling Buildfile '/Applications/MAMP/bin/php5/lib/php/symfony/vendor/propel-generator/build-propel.xml'
> with target 'om'
>          [property] Loading /Applications/MAMP/bin/php5/lib/php/symfony/vendor/propel-generator/./default.properties
>         
>         propel > check-run-only-on-schema-change:
>         
>         propel > om-check:
>         
>         propel > om:
>              [echo] +------------------------------------------+
>              [echo] |                                          |
>              [echo] | Generating Peer-based Object Model for   |
>              [echo] | YOUR Propel project! (NEW OM BUILDERS)!  |
>              [echo] |                                          |
>              [echo] +------------------------------------------+
>         [phingcall] Calling Buildfile '/Applications/MAMP/bin/php5/lib/php/symfony/vendor/propel-generator/build-propel.xml'
> with target 'om-template'
>          [property] Loading /Applications/MAMP/bin/php5/lib/php/symfony/vendor/propel-generator/./default.properties
>         
>         propel > om-template:
>         [PHP Error] strftime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting
> or the date_default_timezone_set() function. In case you used any of
> those methods and you are still getting this warning, you most likely
> misspelled the timezone identifier. We selected 'Asia/Tokyo' for
> 'JST/9.0/no DST' instead [line 539 of
> /Applications/MAMP/bin/php5/lib/php/symfony/vendor/propel-generator/classes/propel/phing/AbstractPropelDataModelTask.php]
>         [propel-om] Target database type: mysql
>         [propel-om] Target package: lib.model
>         [propel-om] Using template path: /Applications/MAMP/bin/php5/lib/php/symfony/vendor/propel-generator/templates
>         [propel-om] Output directory: /Applications/MAMP/htdocs/hatch/sf_fail
>         [propel-om] Processing: generated-schema.xml
>         [propel-om] Processing Datamodel : JoinedDataModel
>         [propel-om]   - processing database : propel
>         [propel-om]   + user
>         [propel-om]       -> BaseUserPeer [builder: SfPeerBuilder]
>         [propel-om]       -> BaseUser [builder: SfObjectBuilder]
>         [propel-om]       -> UserMapBuilder [builder: SfMapBuilderBuilder]
>         [propel-om]       -> (exists) UserPeer
>         [propel-om]       -> (exists) User
>         [propel-om]   + tag
>         [propel-om]       -> BaseTagPeer [builder: SfPeerBuilder]
>         [propel-om]       -> BaseTag [builder: SfObjectBuilder]
>         [propel-om]       -> TagMapBuilder [builder: SfMapBuilderBuilder]
>         [propel-om]       -> (exists) TagPeer
>         [propel-om]       -> (exists) Tag
>         [propel-om]   + photo
>         [propel-om]       -> BasePhotoPeer [builder: SfPeerBuilder]
>         [propel-om]       -> BasePhoto [builder: SfObjectBuilder]
>         [propel-om]       -> PhotoMapBuilder [builder: SfMapBuilderBuilder]
>         [propel-om]       -> (exists) PhotoPeer
>         [propel-om]       -> (exists) Photo
>         [propel-om]   + idle
>         [propel-om]       -> BaseIdlePeer [builder: SfPeerBuilder]
>         [propel-om]       -> BaseIdle [builder: SfObjectBuilder]
>         [propel-om]       -> IdleMapBuilder [builder: SfMapBuilderBuilder]
>         [propel-om]       -> (exists) IdlePeer
>         [propel-om]       -> (exists) Idle
>         
>         BUILD FINISHED
>         
>         Total time: 1.5223 second
>         >> file-     /Applications/MAMP/htdocs/hatch...ail/config/generated-schema.xml
>         >> schema    converting "/Applications/MAMP/..._fail/config/schema.yml" to XML
>         >> schema    putting /Applications/MAMP/htdo...ail/config/generated-schema.xml
>         Buildfile: /Applications/MAMP/bin/php5/lib/php/symfony/vendor/propel-generator/build.xml
>         [resolvepath] Resolved /Applications/MAMP/htdocs/hatch/sf_fail/config to
> /Applications/MAMP/htdocs/hatch/sf_fail/config
>         
>         propel-project-builder > check-project-or-dir-set:
>         
>         propel-project-builder > check-project-set:
>         
>         propel-project-builder > set-project-dir:
>         
>         propel-project-builder > check-buildprops-exists:
>         
>         propel-project-builder > check-buildprops-for-propel-gen:
>         
>         propel-project-builder > check-buildprops:
>         
>         propel-project-builder > configure:
>              [echo] Loading project-specific props from /Applications/MAMP/htdocs/hatch/sf_fail/config/propel.ini
>          [property] Loading /Applications/MAMP/htdocs/hatch/sf_fail/config/propel.ini
>         
>         propel-project-builder > sql:
>             [phing] Calling Buildfile '/Applications/MAMP/bin/php5/lib/php/symfony/vendor/propel-generator/build-propel.xml'
> with target 'sql'
>          [property] Loading /Applications/MAMP/bin/php5/lib/php/symfony/vendor/propel-generator/./default.properties
>         
>         propel > check-run-only-on-schema-change:
>         
>         propel > sql-check:
>         
>         propel > pgsql-quoting-check:
>         
>         propel > sql:
>              [echo] +------------------------------------------+
>              [echo] |                                          |
>              [echo] | Generating SQL for YOUR Propel project!  |
>              [echo] |                                          |
>              [echo] +------------------------------------------+
>         [phingcall] Calling Buildfile '/Applications/MAMP/bin/php5/lib/php/symfony/vendor/propel-generator/build-propel.xml'
> with target 'sql-template'
>          [property] Loading /Applications/MAMP/bin/php5/lib/php/symfony/vendor/propel-generator/./default.properties
>         
>         propel > sql-template:
>         [propel-sql] Processing: generated-schema.xml
>         [propel-sql] Writing to SQL file: /Applications/MAMP/htdocs/hatch/sf_fail/data/sql/lib.model.schema.sql
>         [propel-sql]  + user [builder: MysqlDDLBuilder]
>         [propel-sql]  + tag [builder: MysqlDDLBuilder]
>         [propel-sql]  + photo [builder: MysqlDDLBuilder]
>         [propel-sql]  + idle [builder: MysqlDDLBuilder]
>         
>         BUILD FINISHED
>         
>         Total time: 0.3328 seconds
>         >> file-     /Applications/MAMP/htdocs/hatch...ail/config/generated-schema.xml
>         >> schema    converting "/Applications/MAMP/..._fail/config/schema.yml" to XML
>         >> schema    putting /Applications/MAMP/htdo...ail/config/generated-schema.xml
>         Buildfile: /Applications/MAMP/bin/php5/lib/php/symfony/vendor/propel-generator/build.xml
>         [resolvepath] Resolved /Applications/MAMP/htdocs/hatch/sf_fail/config to
> /Applications/MAMP/htdocs/hatch/sf_fail/config
>         
>         propel-project-builder > check-project-or-dir-set:
>         
>         propel-project-builder > check-project-set:
>         
>         propel-project-builder > set-project-dir:
>         
>         propel-project-builder > check-buildprops-exists:
>         
>         propel-project-builder > check-buildprops-for-propel-gen:
>         
>         propel-project-builder > check-buildprops:
>         
>         propel-project-builder > configure:
>              [echo] Loading project-specific props from /Applications/MAMP/htdocs/hatch/sf_fail/config/propel.ini
>          [property] Loading /Applications/MAMP/htdocs/hatch/sf_fail/config/propel.ini
>         
>         propel-project-builder > insert-sql:
>             [phing] Calling Buildfile '/Applications/MAMP/bin/php5/lib/php/symfony/vendor/propel-generator/build-propel.xml'
> with target 'insert-sql'
>          [property] Loading /Applications/MAMP/bin/php5/lib/php/symfony/vendor/propel-generator/./default.properties
>         
>         propel > insert-sql:
>         [propel-sql-exec] Executing statements in file: /Applications/MAMP/htdocs/hatch/sf_fail/data/sql/lib.model.schema.sql
>         [propel-sql-exec] Our new url -> mysql://root:root@localhost/sf_fail
>         Execution of target "insert-sql" failed for the following reason:
> /Applications/MAMP/bin/php5/lib/php/symfony/vendor/propel-generator/build-propel.xml:296:1:
> [wrapped: connect failed [Native Error: No such file or directory]
> [User Info: Array]]
>             [phing] /Applications/MAMP/bin/php5/lib/php/symfony/vendor/propel-generator/build-propel.xml:296:1:
> [wrapped: connect failed [Native Error: No such file or directory]
> [User Info: Array]]
>     
>     BUILD FINISHED
>     
>     Total time: 0.1648 seconds
>     >> file-     /Applications/MAMP/htdocs/hatch...ail/config/generated-schema.xml

2 个答案:

答案 0 :(得分:0)

Propel 1.2中的一些错误消息(捆绑版本)可以做得更有帮助,这是肯定的。它也不使用PDO,因此比最新版本慢得多。我建议你至少升级到Symfony 1.3,它安装了更好的Propel版本。

@richsage推荐使用Symfony 1.4,但是在我的拙见中,执行的表单系统非常过于复杂。 Symfony 1.3也有它,但至少在那里你可以切换到10兼容模式(我完全忘记了它的名称) - 这让你可以回到组件助手的方法。此外,您可以通过添加插件在Symfony 1.3(或1.4)中将您的Propel版本升级到1.6。

答案 1 :(得分:0)

类似问题

[wrapped: connect failed [Native Error: No such file or directory] [User Info: Array]]

与旧的Symfony1项目在工作中遇到了完全相同的问题,对我有用的修复方法是更改​​databases.yml: -

mysql://root:@localhost/database_name_here

mysql://root:@127.0.0.1/database_name_here 

这个问题的根本问题是原始开发环境是在Windows上设置的,而我的开发环境是在Mac上。这对你来说可能不是一样的情况,但希望能帮助别人,寻找这个错误