驱动程序中发生异常:sqlstate[hy000][14]无法打开数据库文件

ijnw1ujt  于 2021-06-24  发布在  Mysql
关注(0)|答案(2)|浏览(342)

当我想用wamp服务器创建一个新的数据库时,出现了这个错误。我该如何解决
$应用程序/控制台doctrine:database:create无法为名为default的连接创建数据库“symfony”驱动程序中发生异常:sqlstate[hy000][14]无法打开数据库文件

parameters.yml:
    database_driver: pdo_sqlite
    database_host: 127.0.0.1
    database_port: null
    database_name: symfony
    database_user: root
    database_password: null
    database_path: '%kernel.root_dir%/data/blog.sqlite'
    mailer_transport: smtp
    mailer_host: 127.0.0.1
    mailer_user: null
    mailer_password: null
    locale: en
    secret: secret_value_for_symfony_demo_application

参数.yml.dist:


# This file defines the canonical configuration parameters of the application.

    # Symfony uses this file as a template to generate the real app/config/parameters.yml
    # used by the application.
    # See 

http://symfony.com/doc/current/best_practices/configuration.html#canonical-parameters
    parameters:
        # this demo application uses an embedded SQLite database to simplify setup.
        # in a real Symfony application you probably will use a MySQL or PostgreSQL database
    database_driver:   pdo_sqlite
    database_host:     127.0.0.1
    database_port:     ~
    database_name:     symfony
    database_user:     root
    database_password: ~
    # the 'database_path' is only used for SQLite type databases
    database_path:     %kernel.root_dir%/data/blog.sqlite

    # Uncomment these lines to use a MySQL database instead of SQLite:
    #
    # database_driver: pdo_mysql
    # database_host: 127.0.0.1
    # database_port: null
    # database_name: symfony_demo
    # database_user: root
    # database_password: null
    #

 # You can even create the database and load the sample data from the command line:

# 

# $ cd your-symfony-project/

# $ php app/console doctrine:database:create

# $ php app/console doctrine:schema:create

# $ php app/console doctrine:fixtures:load

# If you don't use a real mail server, you can send emails via your Gmail account.

    # see http://symfony.com/doc/current/cookbook/email/gmail.html
mailer_transport:  smtp
mailer_host:       127.0.0.1
mailer_user:       ~
mailer_password:   ~

# The code of the default language used by the application ('en' = English)

locale: en

# The 'secret' value is a random string of characters, numbers and symbols

# used internally by Symfony in several places (CSRF tokens, URI signing,

# 'Remember Me' functionality, etc.)

# see: http://symfony.com/doc/current/reference/configuration/framework.html#secret

secret: 'secret_value_for_symfony_demo_application'
lx0bsm1f

lx0bsm1f1#

出现此消息的一个原因是用户无法在 %kernel.root_dir%/data/ 文件夹。检查是否可以在此文件夹中创建文件。

c3frrgcw

c3frrgcw2#

我在config.yml@markus中有这个

doctrine:
        dbal:
            # instead of configuring the database access options in this file, we pull
            # them from the app/config/parameters.yml file. The reason is that config.yml
            # stores options that change the application behavior and parameters.yml
            # stores options that change from one server to another
            driver:   "%database_driver%"
            host:     "%database_host%"
            port:     "%database_port%"
            dbname:   "%database_name%"
            user:     "%database_user%"
            password: "%database_password%"
            charset:  UTF8
            # if using pdo_sqlite as your database driver, add the path in parameters.yml
            # e.g. database_path: "%kernel.root_dir%/data/data.db3"

orm:
    auto_generate_proxy_classes: "%kernel.debug%"
    auto_mapping: true

相关问题