【问题标题】:How to use mysql with a local laravel 8 sail installation如何在本地 laravel 8sai 安装中使用 mysql
【发布时间】:2021-07-29 23:26:42
【问题描述】:

我正在学习 Laravel 8,我是初学者。 我尝试通过 Sail 安装它以利用 Docker。 终端:

curl -s "https://laravel.build/learnlaravel" | bash
cd learnlaravel
./vendor/bin/sail up

现在转到 localhost 我看到 Laravel 欢迎页面,一切正常。

如果我这样做:

php artisan migrate

我收到此错误:

xlf @ MBP16-XLF learnlaravel% php artisan migrate

   Illuminate \ Database \ QueryException

  SQLSTATE [HY000] [2002] No such file or directory (SQL: select * from information_schema.tables where table_schema = learnlaravel and table_name = migrations and table_type = 'BASE TABLE')

  at vendor / laravel / framework / src / Illuminate / Database / Connection.php: 678
    674▕ // If an exception occurs when attempting to run a query, we'll format the error
    675▕ // message to include the bindings with SQL, which will make this exception a
    676▕ // lot more helpful to the developer instead of just the database's errors.
    677▕ catch (Exception $ e) {
  ➜ 678▕ throw new QueryException (
    679▕ $ query, $ this-> prepareBindings ($ bindings), $ e
    680▕);
    681▕}
    682▕

谁能用简单的话向我解释我做错了什么或我应该做什么? mySQL 数据库是否已经在 Docker 上?如何登录以使用 .env 文件的凭据创建和配置它? 感谢您的理解和支持:)

【问题讨论】:

    标签: mysql laravel docker


    【解决方案1】:

    试试

    ./vendor/bin/sail artisan migrate
    

    而不是

    php artisan migrate
    

    文档:https://laravel.com/docs/8.x/artisan#laravel-sail

    此外,您可以安装任何数据库管理器并使用此凭据连接到您的数据库以查看和配置它。

    【讨论】:

    • hello elleVan,感谢您的回答,您的代码返回相同的错误:(
    • @LorenzoFranzone 您是否更改了 .env 文件中的凭据或者它们是默认的? github.com/laravel/framework/issues/19522 - 也许你可以在这里找到解决方案
    • 谢谢,安装sequel ace解决了,因为sequel pro与mysql 8有冲突
    • sequel pro 似乎不适用于sail 和mysql 8。但TablePlus 使用完全相同的设置工作得很好。
    猜你喜欢
    • 2021-03-25
    • 1970-01-01
    • 2014-06-04
    • 1970-01-01
    • 2022-01-02
    • 1970-01-01
    • 1970-01-01
    • 2013-04-16
    • 1970-01-01
    相关资源
    最近更新 更多