<code>.env</code>

问题描述 投票:0回答:1

数据库: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
  • sissue:
  • 当我运行
  • 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

laravel仍在使用旧的缓存配置
更新了您的.env文件,Laravel可能仍在使用缓存的设置。

solution:运行以下命令清除并刷新 配置:

php artisan config:clear php artisan cache:clear php artisan config:cache

laravel config
1个回答
0
投票
    Solution: 使用root(如果您有访问)登录到mySQL并授予必要的特权:
  1. 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:
  1. sudo systemctl restart mysql

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.