I have setup Laravel and trying to run the artisan migrate
command however I am getting the error below
[PDOException] SQLSTATE[HY000] [2002] Connection refused.
I am not sure how db is setup in Homestead. So I got the below questions.
I tried logging in to MySQL db by connecting to Homestead VM using ssh and then running MySQL. However I get error Access denied for user....
for user name vagrant, Homestead and forge.
What is the default credentials? I understand that creating MySQL db is out of the scope of Laravel tutorial; So it would be helpful if anyone can answer these questions and point me in right direction.
Homestead comes with a default database called homestead
. Your app can either choose to hook into that database, or you will have to go and make a new database manually. You can either use a GUI (like Sequel Pro on Mac) or perform it via the command line through Vagrant.
// SSH into the box
vagrant ssh
// Connect to MySQL as the homestead user (password is: secret)
mysql -u homestead -p
// Create a new database in MySQL
CREATE DATABASE your_app_name;
// Leave MySQL
exit;
You can then migrate the database as usual, php artisan migrate
.
If you need to do this with Postgres instead, it's pretty similar.
// Connect to Postgres (password is: secret)
psql -U homestead -h localhost
// Create a new database in Postgres
CREATE DATABASE your_app_name;
// Leave Postgres
\q
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With