Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Ikodiks's avatar

Table not created in mysql after php artisan migrated on homestead

Hi, Im just new in Laravel Homestead. I'm just wondering why the table that migrated not showing up on mysql database.

database.php value:

'mysql' => [ 'driver' => 'mysql', 'host' => env('DB_HOST', 'localhost'), 'database' => env('DB_DATABASE', 'tagalogtms'), 'username' => env('DB_USERNAME', 'root'), 'password' => env('DB_PASSWORD', ''), 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, ],

migration result:

vagrant@homestead:~/laravel_projects/tagalogtms$ php artisan migrate Migrated: 2015_08_31_065320_address_list_table vagrant@homestead:~/laravel_projects/tagalogtms$

Could anyone provide me any idea/s what else need to look on, please? any thought is Much appreaciated.

0 likes
9 replies
Snapey's avatar

what's in your .env file because that will be used in preference to values in your database.php file

Check for another homestead database on your homestead machine

Are you running the migration from the homestead command line?

1 like
bobbybouwmann's avatar

Did you change the values in your .env file?

Let's inspect this line:

 'database' => env('DB_DATABASE', 'tagalogtms')

This will return the result that is set in your .env file, which has a default value of homestead. If there is no value set it will use the default value you specified tagalogtms

Ikodiks's avatar

Thank you guys for quick response!

Here is my .env file:

APP_ENV=local APP_DEBUG=true APP_KEY=.*****.

DB_HOST=localhost DB_DATABASE=homestead DB_USERNAME=homestead DB_PASSWORD=secret

CACHE_DRIVER=file SESSION_DRIVER=file QUEUE_DRIVER=sync

MAIL_DRIVER=smtp MAIL_HOST=mailtrap.io MAIL_PORT=2525 MAIL_USERNAME=null MAIL_PASSWORD=null MAIL_ENCRYPTION=null

Ikodiks's avatar

Yes, I'm running the migration from homestead command line.

Snapey's avatar

your .env is where you should set all the DB connection properties.

you can do it in the database.php file, but only if you remove the database settings from .env

why use .env?

well, it's because these private settings should be kept out of your application in case you push it to a public repository like GitHub. Many people had their sites hacked because they committed their security credentials into GitHub

bobbybouwmann's avatar

You need to set these variables

DB_HOST=localhost 
DB_DATABASE=<database-name>
DB_USERNAME=<database-user>
DB_PASSWORD=<database-password>
Ikodiks's avatar

I set the .env variables as per correct database name, user and corresponding password. These variables are also set on my phpmyadmin database. I set the database.php to default values. Then another problem came out:

[PDOException]
SQLSTATE[HY000] [1045] Access denied for user '.....'@'localhost' (using password: YES).

Seems homestead is not accessing phpmyadmin database... what do you think the issue here?

Ikodiks's avatar

I just notice one thing:

if my .env setting as this :

DB_HOST=localhost DB_DATABASE=mydatabasename DB_USERNAME=homestead DB_PASSWORD=secret

The result: vagrant@homestead:~/laravel_projects/mydatabasename$ php artisan migrate:refresh Rolled back: 2014_10_12_100000_create_password_resets_table Rolled back: 2014_1012000000_create_users_table Migrated: 2014_1012000000_create_users_table Migrated: 2014_10_12_100000_create_password_resets_table

migration shows that was successful, but the username in my phpmyadmin "mydatabasename" is "nothomestead" and password is "notsecret". This is hard to understand why successful and for sure no migrated record reflected in my phpmyadmin database. This is really confusing...

bobbybouwmann's avatar

Because you run Homestead, you already have a database on the server. You probably try to access phpmyadmin on your local machine?

Please or to participate in this conversation.