Laravel PDOException SQLSTATE[HY000] [1049] Unknown database 'forge'
我正在使用Laravel连接到MySQL数据库。
我得到了这个例外:
PDOException
SQLSTATE[HY000] [1049] Unknown database 'forge'
这是我的config.database.php
'mysql' => array(
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'laravel',
'username' => 'Anastasie',
'password' => 'A@Laurent',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
为什么错误是指数据库?为什么是数据库名称?我已经改变了它。PDO
forge
我应该做些什么来告诉Laravel我正在使用MySQL数据库吗?
更新 1
我在我的用户.php文件中找到此行,我已将其更改为,因为我的数据库中的表不是protected $table = 'users';
protected $table = 'user';
user
users
更新 2
我在我的路线中写了这个
Route::resource('users', 'UsersController');
并且我已添加到我的控制器文件夹中UsersController.php
在里面我有这个:UsersController.php
class UsersController extends BaseController {
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$users = User::all();
return View::make('users.index', compact('users'));
}
我称之为网址http://localhost:8082/laravel/public/users/
我正在将 Windows 7 与 Laravel 4.2 配合使用
提前致谢