Laravel应用程序适用于localhost:8000而不是lms.app

时间:2017-06-22 15:10:11

标签: laravel

我开发了一个laravel应用程序。然而,当我用php artisan成功验证后。登录遇到了这个问题

  

SQLSTATE [HY000] [1045]拒绝访问用户'root'@'localhost'(使用密码:NO)(SQL:select * from`users`其中`email` = paulson@gmail.com limit 1)< / p>

只有当我使用lms.app时。当我运行与localhost:8000相同的项目时,一切运行良好。我做了很多编码。我刚刚开始进行身份验证测试

这是我的.env文件

APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:lGuAkp+tlvCJriluZA+KdgWlspUG24Q6OEMLXHGwj6M=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost

DB_CONNECTION=mysql
DB_HOST=localhost
DB_DATABASE=laravel_lms
DB_USERNAME=root
DB_PASSWORD=

BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=

这是我的database.php文件

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

这是我的yaml文件

ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

folders:
    - map: C:\Users\George\Laravel
      to: /home/vagrant/Code

sites:

    - map: lms.app
      to: /home/vagrant/Code/lms/public

databases:
    - homestead

# blackfire:
#     - id: foo
#       token: bar
#       client-id: foo
#       client-token: bar

# ports:
#     - send: 50000
#       to: 5000
#     - send: 7777
#       to: 777
#       protocol: udp

这是我的主人档案

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
#   127.0.0.1       localhost
#   ::1             localhost

192.168.10.10 lms.app

可能是什么问题。我更喜欢运行这个应用程序并像lms.app一样做所有事情

1 个答案:

答案 0 :(得分:0)

好的,你可能没有在宅基地机器上设置你的数据库。

首先使用此命令连接到您的计算机:

vagrant ssh

或者这个

homestead shh

之后你连接到你的数据库(-u是你的用户名和-p你的密码):

mysql -u homestead -p

之后,您可以运行sql命令/迁移来创建数据库和表。

要创建数据库,请运行此示例:

CREATE DATABASE your_app_name;

按照以下步骤告诉我发生了什么事后我会更新我的答案。