I\'m on a Mac OS Yosemite using Laravel 5.0.
While in my local environment, I run php artisan migrate
I keep getting :
TLDR: You need to stop the server Ctrl + c and start again using php artisan serve
If you are using Laravel, and have started local dev server already by php artisan serve
And after having above server already running, you change your database server related stuff in .env file. Like moving from MySQL to SQLite or something. You need to make sure that you stop above process i.e. Ctrcl C
or anything which stop the process. And then restart Artisan Serve again i.e. y php artisan serve
and refresh your browser and your issue related to database will be fixed. This is what worked for me for Laravel 5.3
Got it! Log in as root and grant homestead@localhost the rights to everything.
From your terminal:
$ homestead ssh
$ mysql -u root -p
Enter password: secret
mysql> grant all privileges on *.* to 'homestead'@'localhost' identified by 'secret';
Query OK, 0 rows affected (0.00 sec)
exit
Now homesteads regular user has access to all of your tables, and as such, should be able to run things like migrations.
In Windows PC Follow below.
Access the Root folder of your application.
Edit the .env file
Edit the Highlighted and change the UserName and the password adn The database Name accordingly.
In my case the error was "caused" by my Homestead / Vagrant configuration about which I forgot :) trying to run the migration just from command line.
In case of using Homestead Vagrant Box environment you should run your migration from within your Homestead machine (after connecting to it using ssh: vagrant@192.168.10.10:22
) then the access rights will be OK and will allow the migration to run.
All you have to do is alter your .env file.
DB_HOST=localhost
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
In front of DB_DATABASE, write the name of the database and in front of DB_USERNAME, use root.
just change these things in the .env file of your root folder.
DB_DATABASE=your_db_name
DB_USERNAME=your_db_user_name
DB_PASSWORD='your_db_password'
It worked for me.