嗨我有一个问题,我的laravel没有检测到我的localhost phpmyadmin数据库,我的配置设置为本地主机,我已经尝试将ip更改为127.0.0.1,此时此类问题已暂停 数据库配置:
'fetch' => PDO::FETCH_CLASS,
/*
|--------------------------------------------------------------------------
| Default Database Connection Name
|--------------------------------------------------------------------------
|
| Here you may specify which of the database connections below you wish
| to use as your default connection for all database work. Of course
| you may use many connections at once using the Database library.
|
*/
'default' => env('DB_CONNECTION', 'mysql'),
/*
|--------------------------------------------------------------------------
| Database Connections
|--------------------------------------------------------------------------
|
| Here are each of the database connections setup for your application.
| Of course, examples of configuring each database platform that is
| supported by Laravel is shown below to make development simple.
|
|
| All database work in Laravel is done through the PHP PDO facilities
| so make sure you have the driver for your particular database of
| choice installed on your machine before you begin development.
|
*/
'connections' => [
'mysql' => [
'driver' => 'mysql',
'host' => env('127.0.0.1'),
'database' => env('credito'),
'username' => env('root'),
'password' => env(''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
],
答案 0 :(得分:3)
<强> database.php中强>
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => false,
'engine' => null,
],
.env 以正确的方式更新.env中的值。
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
另一个问题也许 Laravel没有检测到您的应用程序环境。 您可以使用
查看它正在使用的环境 command line: php artisan env
答案 1 :(得分:0)
Just make sure that you have the same credentials
'host' => env('127.0.0.1'),
'database' => env('credito'),
'username' => env('root'),
'password' => env(''),on your config/database.php and .env file, restart your apache server