我使用密码创建具有所有特权'admin'@'localhost'的用户,并添加特定的数据库特权以使用以下方式访问我的api数据库'fundbuz':
CREATE USER 'admin'@'localhost'
IDENTIFIED BY 'secret';
GRANT ALL
ON fundbuz.*
TO 'admin'@'localhost';
FLUSH Privileges;
并使用admin用户成功登录到mysql命令行。 但是当我在lumen api上与该用户配置数据库连接时,出现此错误。
SQLSTATE [HY000] [1045]用户'admin'@'localhost'的访问被拒绝(使用密码:NO
我将apuntu 18.04 vps与apache和php7.2一起使用,mysql 我已经基于本文确保了mysql的安全: https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-phpmyadmin-on-ubuntu-18-04
我也尝试:
php artisan cache:clear
DB_HOST from 127.0.0.1 to localhost and vps ip
将Schema::defaultStringLength(191);
添加到AppServiceProviders
还根据预期文章删除保护我的phpMyAdmin实例的安全。
这是我的.env和config / database.php
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=fundbuz
DB_USERNAME=admin
DB_PASSWORD='secret'
return [
'default' => 'mysql',
'migrations' =>'migrations',
'connections'=>[
'mysql' => [
'driver' =>'mysql',
'host' => env('DB_HOST' ,'localhost'),
'port' => env('DB_PORT' ,3306),
'database' => env('DB_NAME' ,'fundbuz'),
'username' =>env('DB_USERNAME', 'admin'),
'password' => env('DB_PASSWORD' ,''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'strict' =>false,
'option' =>[]
],
'mongodb' => [
'driver' => 'mongodb',
'host' => '127.0.0.1',
'port' => 27017,
'database' => 'project',
'username' => '',
'password' => ''
]
]
];