.env ÎļþÊÇÅaÖÃÎļþ£¬°uÀ¨Êý¾Ý¿aÅaÖÃÐÅÏ¢£¬²e¿´ config->database.php £¬connections ÀiÃae°uº¬ÁËËuÓÐÊý¾Ý¿aµÄÅaÖ㬿ÉÒÔÔÚ default ÖÐÑ¡ÔñҪʹÓõÄÊý¾Ý¿a¡£ÔÚÊý¾Ý¿aÅaÖÃÖУ¬ÓÐ¹Ø env('DB_HOST', 'localhost') ¾ÍÊǶÁÈ¡ .env ÅaÖÃÎļþµÄÐÅÏ¢¡£µÚ¶þ¸o²ÎÊýÊÇȱʡ²ÎÊý¡£
ÎÒÃÇʹÓà mysql Êý¾Ý¿a£¬ÐÞ¸Ä .env:
DB_HOST=localhost
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=
ÔÚmysqlÖд´½¨ laravelÊý¾Ý¿a
mysql -u root
CREATE DATABASE laravel
²e¿´ mysql ÅaÖãº
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
ÔÚ config ×ÓĿ¼ÖУ¬°uº¬ÁËÈ«²¿µÄÅaÖÃÎļþ£¬²e¿´Ò»Ï¡£
ÒÔÉÏËuÊo¾ÍÊDZ¾ÎĵÄÈ«²¿ÄÚÈÝÁË£¬Ï£ÍuÄܹ»¶Ô´o¼ÒѧϰLaravel5¿o¼ÜÓÐËu°iÖu¡£
Copyright© 2013-2020
All Rights Reserved 京ICP备2023019179号-8