Ironheartbj18
Ironheartbj18

Reputation: 85

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

I want to access a Mysql data the first step is to create a new table for "vanvlymen" and I typed mysql> USE vanvlymen; the database changed. and type SHOW tables; showing the available of the tables that the database contains.

mysql -u root -p 
enter password: ****

mysql> show databases;
-databases-

 information_schema
 mysql
 performance_schema
 phpmyadmin
 vanvlymen

 5 rows...

everything is looking good... I have decide to tell mysql to specify the database I am working on before executing the query as "vanvlymen"

app/config/database.php

   'mysql' => array(
        'driver'    => 'mysql',
        'host'      => 'localhost',
        'database'  => 'vanvlymen',
        'username'  => 'foobar',
        'password'  => 'foobar',
        'charset'   => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix'    => '',
    ),

save as file go to FileZilla using FTP find a file drag and drop into my live server overwrite the database.php file.

I have tried to clear the cache like that

 php artisan cache:clear 

 php artisan migrate

it errors:

 SQLSTATE[42000] [1049] unknown database 'forge'. 

Why keeping it said unknown database 'forge' I am excepting to change to vanvlymen database. Should I remove mysql and reinstall?

I am using windows 8.1 with laravel 4.2

Using phpmyadmin, I know what is the password and username to log in.

Upvotes: 2

Views: 34936

Answers (4)

Style Left
Style Left

Reputation: 151

remove two files config.php and services.php in /bootstrap/cache. And try again.

Upvotes: 1

akshay ahir
akshay ahir

Reputation: 61

If you are running both Xampp and MySQL Workbench, or if You are Running Xampp on the port other than the default port, there may be chances of confusion, you may have created the database using PHPMyAdmin and you are trying to connect it to localhost:cusotmport (e.g. localhost:8080). what I suggest is to create the database you want using MySQL workbench and then you would get your task done...

Upvotes: 0

wired00
wired00

Reputation: 14438

Hopefully this will help someone else. I suddenly had an issue where my dev site I was building stopped connecting to the DB, and just as the OP it was saying:

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

After much head scratching (!) I found that my hostname value set inside the /bootstrap/start.php was wrong, because my hostname had changed on my macbook pro!? I have no idea how but it changed from something like RobMacbookPro2.local to RobMacbookPro.local. This meant it fell back to production thus loading the incorrect database.php file with the standard DB=forge (which was wrong)

Check this guide: http://laravel.com/docs/4.2/configuration

Pay particular attention to the code:

<?php

$env = $app->detectEnvironment(array(

    'local' => array('your-machine-name'),

));

On a mac and probably linux? you can determine your hostname by typing # hostname in terminal.

Hope that saves someone some time!

Upvotes: 0

Xyrus
Xyrus

Reputation: 928

Do you have something like app/config/yourEnvironment/database.php ? For example local or production. 'forge' is default name of DB in this config file, so it looks like your app is loading wrong config file.

Upvotes: 0

Related Questions