本文介绍了Laravel宅基地:未知数据库'projectadmin_db'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是laravel的新手.我用宅基地发展.我有两个数据库连接

I am new to laravel. I use homestead for development. I have two database connection

database.php

database.php

'cust_main_db'   =>  [
        'driver'    => 'mysql',
        'host'      => 'localhost',
        'database'  => 'project_db',
        'username'  => 'homestead',
        'password'  => 'secret',
        'charset'   => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix'    => '',
        'strict'    => false,
    ],
    'admin_main_db'   =>  [
        'driver'    => 'mysql',
        'host'      => 'localhost',
        'database'  => 'projectadmin_db',
        'username'  => 'homestead',
        'password'  => 'secret',
        'charset'   => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix'    => '',
        'strict'    => false,
    ],

Homestead.yaml

Homestead.yaml

databases:
    - homestead

在我的本地mysql中,有两个数据库project_dbprojectadmin_db

In my local mysql has both databases project_db and projectadmin_db

当我运行项目http://homestead.app:8000/时,它显示SQLSTATE[HY000] [1049] Unknown database 'projectadmin_db'

When I run the project http://homestead.app:8000/ it shows SQLSTATE[HY000] [1049] Unknown database 'projectadmin_db'

我在这里错过了什么?如果有什么问题请纠正我.

What I have missed here? Correct me if anything wrong.

推荐答案

在Homestead中运行应用程序时,它将在Homestead中查找数据库,而不是实际的本地主机.您可以通过127.0.0.1:33060连接到Homestead的MySQL.

When you run your app in Homestead, it looks for databases in Homestead and not your actual localhost. You can connect to Homestead's MySQL through 127.0.0.1:33060.

这篇关于Laravel宅基地:未知数据库'projectadmin_db'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 18:47