MySQL默认帐户凭据,Laravel Homestead-MySQL默认凭据和数据库

I have setup Laravel and trying to run the artisan migrate command however I am getting the error [PDOException]

SQLSTATE[HY000] [2002] Connection refused.

I am not sure how db is setup in Homestead. So I got the below questions.

Is default database created automatically by artisan migrate or Homestead? If it is, what is the name?

If its not created by default, should we create before running migration?

I tried loggin 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. Thanks.

解决方案

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值