2014-06-09 11:57
浏览 439

Laravel PDOException SQLSTATE [HY000] [1049]未知数据库'forge'

I am using Laravel to connect to MySQL database.

I got this exception:

SQLSTATE[HY000] [1049] Unknown database 'forge'

and this is my config.database.php

'mysql' => array(
            'driver'    => 'mysql',
            'host'      => 'localhost',
            'database'  => 'laravel',
            'username'  => 'Anastasie',
            'password'  => 'A@Laurent',
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',

why is the error referring to PDO database? and why the forge database name? I have already changed it.

Should I do anything to tell Laravel that I am using MySQL database?

Update 1

I found this line protected $table = 'users'; in my user.php file and I have changed it to protected $table = 'user'; because the table in my database is user not users

Update 2

I wrote this in my Route

Route::resource('users', 'UsersController');

and I added UsersController.php in my controllers folder

and inside UsersController.php I have this:

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'));

and I call this url http://localhost:8082/laravel/public/users/

I am using Windows 7 with Laravel 4.2

Thanks in advance

10条回答 默认 最新

相关推荐 更多相似问题