douping6871 2016-05-20 17:37
浏览 133

php artisan migrate:安装无效

I just started downloading laravel 5 today. Where I install my laravel in my desktop. When I try to create a database using laravel comman php artisan migrate:install and it give's me a error SQLSTATE[HY000] [1044] Access denied for user ''@'localhost' to database 'forge' I tried a lot of examples on google but didn't work for me. SC

I follow on of the steps on the internet where I configure my .env file followed the array contain in database.php database to 'forge', username to 'forge' and password to ''

database.php

   'connections' => [

    'sqlite' => [
        'driver' => 'sqlite',
        'database' => env('DB_DATABASE', database_path('database.sqlite')),
        'prefix' => '',
    ],

    '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', ''),
        'charset' => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix' => '',
        'strict' => false,
        'engine' => null,
    ],

    'pgsql' => [
        'driver' => 'pgsql',
        'host' => env('DB_HOST', 'localhost'),
        'port' => env('DB_PORT', '5432'),
        'database' => env('DB_DATABASE', 'forge'),
        'username' => env('DB_USERNAME', 'forge'),
        'password' => env('DB_PASSWORD', ''),
        'charset' => 'utf8',
        'prefix' => '',
        'schema' => 'public',
    ],

],

.env

APP_ENV=local
APP_DEBUG=true
APP_KEY=base64:oqZ6S+IZANLCbszbhef9VSPqd/4rw22oT0mixzsflZo=
APP_URL=http://localhost

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=forge
DB_USERNAME=forge
DB_PASSWORD=''

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=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

How can I create database just typing php artisan migrate:install and automatically create laravel_migration database in my localhost? Just saw this on the internet. But when I did this it didn't create for me.

  • 写回答

1条回答

  • douji6896 2016-05-20 21:51
    关注

    As mentioned in the comments, the tutorial assumes you are using their development virtual machine. Since you're not, you need to start up MySQL and do the following:

    CREATE DATABASE IF NOT EXISTS forge;
    CREATE USER forge@localhost IDENTIFIED BY '';
    GRANT ALL PRIVILEGES ON forge.* TO forge@localhost;
    

    Once the database and user are created, you should be good to go. This should be part of their documentation...

    评论

报告相同问题?

悬赏问题

  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥50 汇编语言除法溢出问题
  • ¥65 C++实现删除N个数据列表共有的元素
  • ¥15 Visual Studio问题
  • ¥15 state显示变量是字符串形式,但是仍然红色,无法引用,并显示类型不匹配
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波