Laravel中用户'homestead'@'localhost'的访问被拒绝

时间:2018-01-26 05:25:18

标签: php laravel

新手在这里。我试着跑:

In Connection.php line 664:

  SQLSTATE[HY000] [1045] Access denied for user 'homestead'@'localhost' (usin  
  g password: YES) (SQL: select * from information_schema.tables where table_  
  schema = homestead and table_name = migrations)                              


In Connector.php line 67:

  SQLSTATE[HY000] [1045] Access denied for user 'homestead'@'localhost' (usin  
  g password: YES)

但是我得到了这些错误:

'mysql' => [
            'driver' => 'mysql',
            'host' => env('DB_HOST', 'localhost'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'strict' => true,
            'engine' => null,
        ],

这是我的database.php和.env文件中分别包含的内容:

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
>>> arr = np.array([[1,2,3],[4,5,6]])
>>> arr
array([[1, 2, 3],
       [4, 5, 6]])
>>> arr[:,0] * 5

我的数据库名称是宅基地,主机是localhost但它仍然提供错误消息。

这就是myPhpAdmin用户帐户概述页面中的内容:
user permissions?

我该如何解决这个问题?

2 个答案:

答案 0 :(得分:2)

如果您使用192.168.10.10而没有任何更改,那么宅基地机器的默认主机为DB_HOST=localhost

更改

DB_HOST=192.168.10.10

OuelletConvexHullAvl2Online.ConvexHullOnline convexHullOnline = new OuelletConvexHullAvl2Online.ConvexHullOnline();
                    foreach (Point pt in points)
                    {
                        convexHullOnline.DynamicallyAddAnotherPointToConvexHullIfAppropriate(pt);
                    }

                    return convexHullOnline.GetResultsAsArrayOfPoint();

链接到Docs

答案 1 :(得分:0)

这意味着您的数据库用户名或密码错误。如果您在Windows上,则默认DB_USERNAME为root,密码为空。尝试在.env文件中更正您的配置。