0

I am following this tutorial here https://www.youtube.com/watch?v=Jbt5bEgv_QM and got stuck in the php artisan migrate part because of this issue. I'm not sure if it's compatibility issue or something. I am fairly new to laravel.

Here's the database.php file and .env file.

database.php

env

UPDATE: i managed to perform the migration using the solutions provided by the user PHP. However, i couldn't find the table in my phpMyAdmin. do i need to change mySQL root password for that? i have actually set the password but in .env and database.php files i left it blank because the migration works that way. if i set the actual password in both files, I'd get access denied error.

Here's the migration files... createuser jobsfail passwordreset

Falady
  • 124
  • 1
  • 15
  • Please read this question and see if it helps: https://stackoverflow.com/questions/51448958/mysql-server-8-0-keyring-migration-error-at-login – Koala Yeung Sep 28 '19 at 15:10
  • hmm I'm not sure if it's related to my issue since i remember my password very well. p/s: i've updated the error above.. i put the wrong one earlier – Falady Sep 28 '19 at 15:14
  • It says "unknown database". Is it possible that you mistyped your database name? – Koala Yeung Sep 28 '19 at 15:16
  • i think i did not mistype my database name. I've checked all files including the one in phpMyAdmin multiple times to make sure.. and that database exists when i checked using `mysql > show database;` command – Falady Sep 28 '19 at 15:18
  • Possible duplicate of [SQLSTATE\[HY000\] \[1045\] Access denied for user 'username'@'localhost' using CakePhp](https://stackoverflow.com/questions/31154124/sqlstatehy000-1045-access-denied-for-user-usernamelocalhost-using-cakep) – Sakthivel A R Sep 28 '19 at 16:59
  • Refer: https://stackoverflow.com/q/31154124/10086603 – Sakthivel A R Sep 28 '19 at 17:00
  • Please don't post screenshots of what can be posted as text (in a code block). – Paul Spiegel Sep 29 '19 at 15:20
  • @WhatIf the migration is successful now but the table is not created in the database.. i have updated the questions above. – Falady Oct 02 '19 at 18:54
  • @Falady Okay, fine. I confirm it as "Migration ran but table not created". Did you check in "migrations" table? – Sakthivel A R Oct 03 '19 at 04:06
  • @WhatIf yes the necessary tables exists but not in my database which is on phpmyadmin. – Falady Oct 03 '19 at 04:18
  • @Falady Check whether the migration name is in "migrations" table. – Sakthivel A R Oct 03 '19 at 04:37
  • post your migration file – Erich Oct 03 '19 at 04:38
  • @Erich i have updated the question.. assuming that it is the correct table you're referring to – Falady Oct 03 '19 at 05:57
  • @Falady not a picture of your files. what table is not being created? post the contents of the file itself (i.e. the code inside 2019_08_19_create_THE_TABLE_THAT_IS_NOT_BEING_CREATED_table.php) – Erich Oct 03 '19 at 13:37
  • if the table you're expecting to see in phpmyadmin doesn't have a migration file named similarly, it won't be created. – Erich Oct 03 '19 at 13:39
  • @Erich have a look at the updated above. and no i couldnt find the migrations table on phpmyadmin. – Falady Oct 03 '19 at 16:26
  • @Falady `php artisan migrate:install` isn't a command you normally have to run. if it does not exist already, that table will be created the first time you migrate. – Erich Oct 03 '19 at 16:53
  • @Erich after many attempts and solutions, i decided to discard this project and create a new one. but then, the first time i try to run `php artisan migrate`, it throws an error saying `unknown database`.....the database exists in the server though. – Falady Oct 08 '19 at 13:55
  • @Falady https://stackoverflow.com/q/25921825/4468423 – Erich Oct 09 '19 at 15:26

3 Answers3

1

Had this issue with a Laravel 10 project and running these commands sorted it for me (run them one by one in the order I've typed them):

php artisan config:cache
php artisan cache:clear
php artisan config:clear
php artisan route:clear
composer dump-autoload
php artisan migrate:fresh --seed 
  • 1
    This answer would benefit from an explanation of why these commands work, to discourage people blindly copying and pasting from the Internet without knowing or understanding what they are doing – Darren H Mar 22 '23 at 09:54
  • 1
    The commands clear laravel caches for route, config etc and generate optimized files. The last command creates tables in the database a fresh and seeds them a fresh too – Daisy Koome Mar 22 '23 at 15:06
0

php artisan migrate:rollback then run php artisan migrate.

If you make changes to your migration files, simply run php artisan migrate:refresh

VIKAS KATARIYA
  • 5,867
  • 3
  • 17
  • 34
  • I did that already..does it have anything to do with root password? In the `.env` and `database.php` I left the password blank, when there is actually a real password. But if I set the password in both files, it will throw `access denied` – Falady Oct 03 '19 at 05:36
  • please don't throw darts at the problem and post them as separate answers. – Erich Oct 03 '19 at 13:49
-1

1)First you have to Create your related Database.

2)Then:php artisan cache:clear

3)Now run php artisan migrate:install

VIKAS KATARIYA
  • 5,867
  • 3
  • 17
  • 34