Home > Backend Development > PHP Tutorial > laravel 数据库查询BUG

laravel 数据库查询BUG

WBOY
Release: 2016-06-06 20:09:44
Original
1080 people have browsed it

上午我安装了laravel 12.2.0版本出现
Base table or view not found: 1146 Table 'homestead.fyl_menu' doesn't exist (SQL: select * from fyl_menu)
错误。
我laravel 配置文件

<code>'mysql' => [
            'driver'    => 'mysql',
            'host'      => env('DB_HOST', 'localhost'),
            'database'  => env('DB_DATABASE', 'fyl'),
            'username'  => env('DB_USERNAME', 'homestead'),
            'password'  => env('DB_PASSWORD', 'secret'),
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
            'strict'    => false,
        ],
</code>
Copy after login
Copy after login

我数据库中fyl数据库中确实存在fyl_menu表. 可惜错误信息确实提示homestead.fyl_menu问题。在laravl框架中 IlluminateDatabaseDatabaseManager  中makeConnection方法   打印config变量输出homestead数据。配置文件中其他字段修改都有效。
希望熟悉lavavel的小伙伴帮一下。

回复内容:

上午我安装了laravel 12.2.0版本出现
Base table or view not found: 1146 Table 'homestead.fyl_menu' doesn't exist (SQL: select * from fyl_menu)
错误。
我laravel 配置文件

<code>'mysql' => [
            'driver'    => 'mysql',
            'host'      => env('DB_HOST', 'localhost'),
            'database'  => env('DB_DATABASE', 'fyl'),
            'username'  => env('DB_USERNAME', 'homestead'),
            'password'  => env('DB_PASSWORD', 'secret'),
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
            'strict'    => false,
        ],
</code>
Copy after login
Copy after login

我数据库中fyl数据库中确实存在fyl_menu表. 可惜错误信息确实提示homestead.fyl_menu问题。在laravl框架中 IlluminateDatabaseDatabaseManager  中makeConnection方法   打印config变量输出homestead数据。配置文件中其他字段修改都有效。
希望熟悉lavavel的小伙伴帮一下。

配置文件在.env

env('DB_HOST', 'localhost') 这样写表示,他回去.env文件里找DB_HOST,如果找不到,就用他后面的localhost

最好不要在config/database.php文件里配置数据库,一般都在.env文件配置,因为你使用给git的话,.env 文件是在.gitignore文件忽略提交的,你如果配置在datebase文件的话,数据库配置数据大家都可以看了,很不安全

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template