数据库:mysql
OS:Ubuntu22.04 My.env文件:DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=react_breeze
DB_USERNAME=other_username_than_root
DB_PASSWORD=password
php artisan migrate
php artisan cache:clear
SQLSTATE[HY000] [1698]访问用户'root'@'localhost'(连接:mysql,sql:delete from
cache
)
)当我尝试时,我会遇到同样的问题
rm -rf bootstrap/cache/config.php
php artisan config:clear
php artisan cache:clear
php artisan config:cache
solution:运行以下命令清除并刷新 配置:laravel仍在使用旧的缓存配置 更新了您的.env文件,Laravel可能仍在使用缓存的设置。
php artisan config:clear
php artisan cache:clear
php artisan config:cache
sudo mysql -u root -p
,然后执行:
GRANT ALL PRIVILEGES ON react_breeze.* TO
'other_username_than_root'@'localhost' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
EXIT;
trory重新启动mysql: sudo systemctl restart mysql