How to configure MariaDB in Laravel 5?
The thread above mentioned that changing port 3306 to 3307,I tried it but still not work.
I write my code on local Windows,the port is also 3306, and the app can run, I copy the app to cloud host,OS is CentOs 7.2,the error appears.
And I am using Laravel 5.3
and mariaDB 10.2
.
The .env
file is like this:
DB_USERNAME=root
DB_PASSWORD=123456
config/database.php
'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' => true,
'engine' => null,
],
I can access it via terminal:
# mysql -uroot -p123456;
MariaDB [(none)]>
When running php artisan migrate
,there is an error:
[PDOException]
SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO)
What should I do?
check your DB_PASSWORD
setting in .env
file.
The error information says that using password: NO
which meant no password used when connecting to db.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.