Laravel + Vagrant = 用户 'root'@'localhost' 拒绝访问 [英] Laravel + Vagrant = Access denied for user 'root'@'localhost'

查看:57
本文介绍了Laravel + Vagrant = 用户 'root'@'localhost' 拒绝访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到 stackoverflow 上的许多用户都有类似的问题,但按照答案我无法使其正常工作.

I've seen that many users here on stackoverflow have a similar issue but following the answers I'm not able to make it work.

当我跑步时:

php artisan migrate

我明白了:

[PDOException]                                                                         
SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: NO) 

这是我的 app/config/app.php

This is my app/config/app.php

'mysql' => array(
            'driver'    => 'mysql',
            'host'      => 'localhost',
            'database'  => 'mio_sito',
            'username'  => 'root',
            'password'  => '',
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
        ),

问题是我实际上没有密码,如果我用以下方式登录 vagrant:

The problem is that I don't actually have a password, if I login to vagrant with:

vagrant ssh

我可以通过以下方式访问 mysql:

I can access mysql with:

mysql -u root

并且不需要密码.
我该如何解决这个问题?

and no password is required.
How can I fix this issue?

推荐答案

根据 Laravel 文档:

要通过 Navicat 或 Sequel Pro 从主机连接到 MySQL 或 Postgres 数据库,您应该连接到 127.0.0.1 和端口 33060 (MySQL) 或 54320 (Postgres).两个数据库的用户名和密码都是 homestead/secret.

To connect to your MySQL or Postgres database from your main machine via Navicat or Sequel Pro, you should connect to 127.0.0.1 and port 33060 (MySQL) or 54320 (Postgres). The username and password for both databases is homestead / secret.

我是如何测试的(Windows 7 x64 - git bash):

$ vagrant up
$ vagrant ssh
vagrant@homestead:~$ mysql -u root -p
vagrant@homestead:~$ 秘密
mysql>

$ vagrant up
$ vagrant ssh
vagrant@homestead:~$ mysql -u root -p
vagrant@homestead:~$ secret
mysql>

这篇关于Laravel + Vagrant = 用户 'root'@'localhost' 拒绝访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆