1

I am new with laravel and I want to migrate the table first I change .env information (database name, password,user name)and I made the model and write the proprieties but when I write the command php artisan migrate the tables did not appear in my phpmyadmin database and the following error appears:

SQLSTATE[HY000] [1044] Access denied for user ''@'localhost' to database 'forge' 
(SQL: select * from information_schema.tables where table_schema = forge and 
table_name = migrations and table_type = 'BASE TABLE') catch (Exception $e) {
 > 664| throw new QueryException( 665| $query, $this->prepareBindings($bindings), 
$e 666| ); 667| } ...
3
  • 1
    what is the error and add some more details Jul 14, 2019 at 8:45
  • please post the error so people can help you with that and make sure you are connected with your database
    – Farshad
    Jul 14, 2019 at 8:57
  • this is the error appeared Illuminate\Database\QueryException : SQLSTATE[HY000] [1044] Access denied for user ''@'localhost' to database 'forge' (SQL: select * from information_schema.tables where table_schema = forge and table_name = migrations and table_type = 'BASE TABLE') catch (Exception $e) { > 664| throw new QueryException( 665| $query, $this->prepareBindings($bindings), $e 666| ); 667| }
    – sarah
    Jul 14, 2019 at 9:01

4 Answers 4

2

Make sure you create a blank database before running the migration.

I suggest you create new user and password in your sql and
GRANT ALL on <'name_of_your_database'>

Then update your .env file same as your database user credentials and migrate it.

1

try this:

  1. composer du.
  2. php artisan make:migration create_model_table.
  3. php artisan migrate.
    you must be sure that you entered the right db credintials.
0

Make sure you are running command in desire project. Have you created migration file for your model by

php artisan make:migration create_model_name

Update the column in migration file and then run

php artisan migrate
1
  • once check in .env file is database username and password. is it correct ? Are you using xamp or wamp for server Jul 14, 2019 at 9:04
0

If you run your project by php artisan serve turn it off and run it again. If not you need to check your credentials to your mysql

4
  • how can i run it off?
    – sarah
    Jul 14, 2019 at 9:12
  • Just stop terminal or batch or what ever you ran it on it. Jul 14, 2019 at 9:13
  • If you are using windows press ctrl + c Jul 14, 2019 at 9:14
  • I am using mac laptop
    – sarah
    Jul 14, 2019 at 16:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.