I am using Laravel to connect to MySQL database.
I got this exception:
PDOException
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?
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
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
You have to clear the cache like that (because your old configuration is in you cache file) :
php artisan cache:clear
The pdo error comes from the fact Laravel use the pdo driver to connect to mysql
php artisan cache:clear php artisan migrate:install
Hope your problem will get resolved.
Using phpMyAdmin (or whatever you prefer), I just created a database called "forge" and re-ran the php artisan migrate command and it all worked.
write
php artisan config:cache 
in your terminal and it will be fixed
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With