Laravel 7.x 無法遠端連線數據庫?

发布于 2022-09-13 00:19:04 字数 1024 浏览 17 评论 0

這是我在 .env 的設定

DB_CONNECTION=mysql
DB_HOST=xxx.xxx.xxx.xxx
DB_PORT=3306
DB_DATABASE=abc
DB_USERNAME=root
DB_PASSWORD=abc

xxx.xxx.xxx.xxx 是我server位置

我在我本地local下
mysql -u root -p -h xxx.xxx.xxx.xxx 試著遠端登入
是成功的

public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('email');
            $table->timestamps();
        });
    }

但我下 $ php artisan migrate 出現錯誤


   Illuminate\Database\QueryException 

  SQLSTATE[HY000] [1045] Access denied for user 'root'@'*******' (using password: YES) (SQL: select * from information_schema.tables where table_schema = abc and table_name = migrations and table_type = 'BASE TABLE')

我的phpmyadmin 已經設置帳戶
Screen Shot 2021-06-25 at 1.57.36 AM.png

有人有遇過嗎?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

酸甜透明夹心 2022-09-20 00:19:04

Mysql分配用户权限

grant all privileges on *.* to root@'%' identified by 'root' WITH GRANT OPTION;

flush privileges;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文