mysql - 如何在本地 laravel 8sai 安装中使用 mysql
问题描述
我正在学习 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 文件的凭据创建和配置它?谢谢你的理解和支持 :)
解决方案
尝试
./vendor/bin/sail artisan migrate
代替
php artisan migrate
文档:https ://laravel.com/docs/8.x/artisan#laravel-sail
此外,您可以安装任何数据库管理器并使用此凭据连接到您的数据库以查看和配置它。
推荐阅读
- python - 如何在 python 中获取 Wifi IP
- c - CYGWIN 控制台中的奇怪错误“检测到 cygheap 基础不匹配”
- javascript - 如何在错误对话框显示中显示 php 错误消息?
- java - Android - 视频活动
- python - 使用 python 并行运行 n 个 MATLAB 实例
- javascript - AJAX:如何在 vanilla JS 中通过 POST 发送简单参数
- python - 循环的条件下拉菜单未按预期方式工作
- sql - 如何在 SQL 中使用带有 While 循环的 openxml 将数据存储在表中以用于多个 XML
- signalr - Blazor 服务器端上的 Asp.Net Core SignalR 从不调用 OnDisconnectedAsync
- reactjs - 如何将surveyjs与react和typescript一起使用