Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel Migration - Says unknown database, but it is created

when I use php artisan migrate, i get the error SQLSTATE[42000] [1049] Unknown database 'databaseName'.

But the database DOES exists! I even tried going back into terminal, logged into mysql and created the database again, and it said that database already exists!

Why is this giving me this error?

like image 975
Kousha Avatar asked Oct 29 '25 17:10

Kousha


2 Answers

I have the same problem. When I run: php artisan migrate. In my case I use Vagrant with scotch box.

To solve this, enter:

  1. vagrant ssh
  2. cd /var/www/yourproject
  3. php artisan migrate

And all work well.

like image 193
user6008095 Avatar answered Oct 31 '25 08:10

user6008095


In your app/config/database.php file change the default value from databaseName to a real database name that you are trying to use in your application, something like this (for mysql driver):

'mysql' => array(
    'driver'    => 'mysql',
    'host'      => 'localhost',
    'database'  => 'your database name', //<-- put the database name
    'username'  => 'your user name',
    'password'  => 'your password',
    'charset'   => 'utf8',
    'collation' => 'utf8_unicode_ci',
    'prefix'    => '',
),
like image 32
The Alpha Avatar answered Oct 31 '25 09:10

The Alpha



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!