我剛剛從Laravel開始,我對數據庫有一些問題。我試圖讓一個PHP遷移並得到了以下錯誤:laravel中的數據庫訪問被拒絕
這裏是我的database.php中的文件:
[...]
'default' => env('DB_CONNECTION', 'mysql'),
[...]
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'laravel'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', 'password'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
'engine' => null,
'port' => env('DB_PORT', 3306),
],
和我.ENV:
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=33060
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD='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=
我嘗試了幾個東西,如替換localhost
由192.168.10.10
或127.0.0.1
在我的.env,但我仍然有一個錯誤。我也試圖做的事: mysqladmin -u homestead -p status Enter password: secret
但它不工作,他們要求輸入密碼,並不管我怎麼說,他們告訴我error: 'Access denied for user 'homestead'@'localhost' (using password: YES)'
確保您的數據庫憑據是正確的,兩次檢查 –
DB_PASSWORD = '密碼' 刪除'''如果只是'password' –
你真的有本地主機上運行的數據庫? – Jerodev