dongle3217 2017-04-02 14:02
浏览 242
已采纳

php artisan migrate - SQLSTATE [HY000] [1045]访问被拒绝用户'laravel'@'localhost'

I want to set up and learn laravel following this course: https://laracasts.com/series/laravel-from-scratch-2017/episodes/4

When I try to use the command php artisan migrate I get this error:

[Illuminate\Database\QueryException]                                                                                                        
  SQLSTATE[HY000] [1045] Access denied for user 'laravel'@'localhost' (using password: NO) (SQL: select * from information_schema.tables whe  
  re table_schema = laravel and table_name = migrations)

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

Tryied to look for answers, I figured I may make some changes in the .env file, but don't know what, nothing has worked so far.

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=laravel
DB_PASSWORD=

I'm using Ubuntu 16.04 not a Mac OS X as in the video, so I wonder what should I do differently? Is there some mysql setting I did not make?

  • 写回答

10条回答 默认 最新

  • douqian2957 2017-04-03 08:26
    关注

    You don't have a user named 'laravel'. You should change the DB_USERNAME to the one you're actually using to access your DB. Mostly it's root by default so the changes in .env should be

    DB_CONNECTION=mysql
    DB_HOST=127.0.0.1
    DB_PORT=3306
    DB_DATABASE=laravel
    DB_USERNAME=root
    DB_PASSWORD=
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(9条)

报告相同问题?

悬赏问题

  • ¥15 求给定范围的全体素数p的(p-2)的连乘积
  • ¥15 VFP如何使用阿里TTS实现文字转语音?
  • ¥100 需要跳转番茄畅听app的adb命令
  • ¥50 寻找一位有逆向游戏盾sdk 应用程序经验的技术
  • ¥15 请问有用MZmine处理 “Waters SYNAPT G2-Si QTOF质谱仪在MSE模式下采集的非靶向数据” 的分析教程吗
  • ¥50 opencv4nodejs 如何安装
  • ¥15 adb push异常 adb: error: 1409-byte write failed: Invalid argument
  • ¥15 nginx反向代理获取ip,java获取真实ip
  • ¥15 eda:门禁系统设计
  • ¥50 如何使用js去调用vscode-js-debugger的方法去调试网页