草庐IT

php - 拉维尔 5.6 | PHP artisan 迁移不工作

coder 2024-04-21 原文

我已经尝试了很多我在谷歌搜索这个问题时看到的东西,但还没有对我有用。

我正在运行带有 MAMP 的 Mac OS 10.13.4。此命令适用于我的带有 XAMPP 的 Windows 机器。

我尝试过的事情:

  • 更改:`127.0.0.1` 为 `.env` 中的 `localhost`
  • 更改:`DB_PORT` 从 `3306` 到 `.env` 中的 `8889`
  • 添加:`'unix_socket' => '/tmp/mysql.sock'`,到 `config\database.php`

这是在终端中输入 php artisan migrate -v 时返回的内容。

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

  at /Users/blazerowland/Documents/Sites/Personal/Portfolio/vendor/laravel/framework/src/Illuminate/Database/Connection.php: 664
  660:         // If an exception occurs when attempting to run a query, we'll format the error
  661:         // message to include the bindings with SQL, which will make this exception a
  662:         // lot more helpful to the developer instead of just the database's errors.
  663:         catch (Exception $e) {
  664:             throw new QueryException(
  665:                 $query, $this->prepareBindings($bindings), $e
  666:             );
  667:         }
  668: 
  669:         return $result;

  Exception trace:

  1   PDOException::("SQLSTATE[HY000] [2002] No such file or directory")
      /Users/blazerowland/Documents/Sites/Personal/Portfolio/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php : 68

  2   PDO::__construct("mysql:unix_socket=/tmp/mysql.sock;dbname=b_rowland", "root", "", [])
      /Users/blazerowland/Documents/Sites/Personal/Portfolio/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php : 68

  3   Illuminate\Database\Connectors\Connector::createPdoConnection("mysql:unix_socket=/tmp/mysql.sock;dbname=b_rowland", "root", "", [])
      /Users/blazerowland/Documents/Sites/Personal/Portfolio/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php : 44

  4   Illuminate\Database\Connectors\Connector::createConnection("mysql:unix_socket=/tmp/mysql.sock;dbname=b_rowland", [])
      /Users/blazerowland/Documents/Sites/Personal/Portfolio/vendor/laravel/framework/src/Illuminate/Database/Connectors/MySqlConnector.php : 24

  5   Illuminate\Database\Connectors\MySqlConnector::connect()
      /Users/blazerowland/Documents/Sites/Personal/Portfolio/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php : 183

  6   Illuminate\Database\Connectors\ConnectionFactory::Illuminate\Database\Connectors\{closure}()
      /Users/blazerowland/Documents/Sites/Personal/Portfolio/vendor/laravel/framework/src/Illuminate/Database/Connection.php : 915

  7   call_user_func(Object(Closure))
      /Users/blazerowland/Documents/Sites/Personal/Portfolio/vendor/laravel/framework/src/Illuminate/Database/Connection.php : 915

  8   Illuminate\Database\Connection::getPdo()
      /Users/blazerowland/Documents/Sites/Personal/Portfolio/vendor/laravel/framework/src/Illuminate/Database/Connection.php : 940

  9   Illuminate\Database\Connection::getReadPdo()
      /Users/blazerowland/Documents/Sites/Personal/Portfolio/vendor/laravel/framework/src/Illuminate/Database/Connection.php : 399

  10  Illuminate\Database\Connection::getPdoForSelect()
      /Users/blazerowland/Documents/Sites/Personal/Portfolio/vendor/laravel/framework/src/Illuminate/Database/Connection.php : 325

  11  Illuminate\Database\Connection::Illuminate\Database\{closure}("select * from information_schema.tables where table_schema = ? and table_name = ?")
      /Users/blazerowland/Documents/Sites/Personal/Portfolio/vendor/laravel/framework/src/Illuminate/Database/Connection.php : 657

  12  Illuminate\Database\Connection::runQueryCallback("select * from information_schema.tables where table_schema = ? and table_name = ?", Object(Closure))
      /Users/blazerowland/Documents/Sites/Personal/Portfolio/vendor/laravel/framework/src/Illuminate/Database/Connection.php : 624

  13  Illuminate\Database\Connection::run("select * from information_schema.tables where table_schema = ? and table_name = ?", Object(Closure))
      /Users/blazerowland/Documents/Sites/Personal/Portfolio/vendor/laravel/framework/src/Illuminate/Database/Connection.php : 333

  14  Illuminate\Database\Connection::select("select * from information_schema.tables where table_schema = ? and table_name = ?")
      /Users/blazerowland/Documents/Sites/Personal/Portfolio/vendor/laravel/framework/src/Illuminate/Database/Schema/MySqlBuilder.php : 18

  15  Illuminate\Database\Schema\MySqlBuilder::hasTable("migrations")
      /Users/blazerowland/Documents/Sites/Personal/Portfolio/vendor/laravel/framework/src/Illuminate/Database/Migrations/DatabaseMigrationRepository.php : 169

  16  Illuminate\Database\Migrations\DatabaseMigrationRepository::repositoryExists()
      /Users/blazerowland/Documents/Sites/Personal/Portfolio/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php : 545

  17  Illuminate\Database\Migrations\Migrator::repositoryExists()
      /Users/blazerowland/Documents/Sites/Personal/Portfolio/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php : 97

  18  Illuminate\Database\Console\Migrations\MigrateCommand::prepareDatabase()
      /Users/blazerowland/Documents/Sites/Personal/Portfolio/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php : 63

  19  Illuminate\Database\Console\Migrations\MigrateCommand::handle()
      /Users/blazerowland/Documents/Sites/Personal/Portfolio/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php : 29

  20  call_user_func_array([])
      /Users/blazerowland/Documents/Sites/Personal/Portfolio/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php : 29

  21  Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
      /Users/blazerowland/Documents/Sites/Personal/Portfolio/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php : 87

  22  Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Object(Closure))
      /Users/blazerowland/Documents/Sites/Personal/Portfolio/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php : 31

  23  Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), [])
      /Users/blazerowland/Documents/Sites/Personal/Portfolio/vendor/laravel/framework/src/Illuminate/Container/Container.php : 564

  24  Illuminate\Container\Container::call()
      /Users/blazerowland/Documents/Sites/Personal/Portfolio/vendor/laravel/framework/src/Illuminate/Console/Command.php : 183

  25  Illuminate\Console\Command::execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
      /Users/blazerowland/Documents/Sites/Personal/Portfolio/vendor/symfony/console/Command/Command.php : 252

  26  Symfony\Component\Console\Command\Command::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
      /Users/blazerowland/Documents/Sites/Personal/Portfolio/vendor/laravel/framework/src/Illuminate/Console/Command.php : 170

  27  Illuminate\Console\Command::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      /Users/blazerowland/Documents/Sites/Personal/Portfolio/vendor/symfony/console/Application.php : 865

  28  Symfony\Component\Console\Application::doRunCommand(Object(Illuminate\Database\Console\Migrations\MigrateCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      /Users/blazerowland/Documents/Sites/Personal/Portfolio/vendor/symfony/console/Application.php : 241

  29  Symfony\Component\Console\Application::doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      /Users/blazerowland/Documents/Sites/Personal/Portfolio/vendor/symfony/console/Application.php : 143

  30  Symfony\Component\Console\Application::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      /Users/blazerowland/Documents/Sites/Personal/Portfolio/vendor/laravel/framework/src/Illuminate/Console/Application.php : 88

  31  Illuminate\Console\Application::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      /Users/blazerowland/Documents/Sites/Personal/Portfolio/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php : 122

  32  Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      /Users/blazerowland/Documents/Sites/Personal/Portfolio/artisan : 37

最佳答案

在您的 .env 文件中,关于您的数据库配置,您是否填写了所有设置?

这是环境变量:

DB_CONNECTION=
DB_HOST=
DB_PORT=
DB_DATABASE=
DB_USERNAME=
DB_PASSWORD=

此外,如果您要起诉 mysql sock,则需要 DB_SOCKET=< path="">/mysql.sock

关于php - 拉维尔 5.6 | PHP artisan 迁移不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49834756/

有关php - 拉维尔 5.6 | PHP artisan 迁移不工作的更多相关文章

  1. ruby-on-rails - Ruby on Rails 迁移,将表更改为 MyISAM - 2

    如何正确创建Rails迁移,以便将表更改为MySQL中的MyISAM?目前是InnoDB。运行原始执行语句会更改表,但它不会更新db/schema.rb,因此当在测试环境中重新创建表时,它会返回到InnoDB并且我的全文搜索失败。我如何着手更改/添加迁移,以便将现有表修改为MyISAM并更新schema.rb,以便我的数据库和相应的测试数据库得到相应更新? 最佳答案 我没有找到执行此操作的好方法。您可以像有人建议的那样更改您的schema.rb,然后运行:rakedb:schema:load,但是,这将覆盖您的数据。我的做法是(假设

  2. ruby-on-rails - 由于 "wkhtmltopdf",PDFKIT 显然无法正常工作 - 2

    我在从html页面生成PDF时遇到问题。我正在使用PDFkit。在安装它的过程中,我注意到我需要wkhtmltopdf。所以我也安装了它。我做了PDFkit的文档所说的一切......现在我在尝试加载PDF时遇到了这个错误。这里是错误:commandfailed:"/usr/local/bin/wkhtmltopdf""--margin-right""0.75in""--page-size""Letter""--margin-top""0.75in""--margin-bottom""0.75in""--encoding""UTF-8""--margin-left""0.75in""-

  3. ruby-on-rails - 'compass watch' 是如何工作的/它是如何与 rails 一起使用的 - 2

    我在我的项目目录中完成了compasscreate.和compassinitrails。几个问题:我已将我的.sass文件放在public/stylesheets中。这是放置它们的正确位置吗?当我运行compasswatch时,它不会自动编译这些.sass文件。我必须手动指定文件:compasswatchpublic/stylesheets/myfile.sass等。如何让它自动运行?文件ie.css、print.css和screen.css已放在stylesheets/compiled。如何在编译后不让它们重新出现的情况下删除它们?我自己编译的.sass文件编译成compiled/t

  4. ruby - 使用 Vim Rails,您可以创建一个新的迁移文件并一次性打开它吗? - 2

    使用带有Rails插件的vim,您可以创建一个迁移文件,然后一次性打开该文件吗?textmate也可以这样吗? 最佳答案 你可以使用rails.vim然后做类似的事情::Rgeneratemigratonadd_foo_to_bar插件将打开迁移生成的文件,这正是您想要的。我不能代表textmate。 关于ruby-使用VimRails,您可以创建一个新的迁移文件并一次性打开它吗?,我们在StackOverflow上找到一个类似的问题: https://sta

  5. ruby - 无法让 RSpec 工作—— 'require' : cannot load such file - 2

    我花了三天的时间用头撞墙,试图弄清楚为什么简单的“rake”不能通过我的规范文件。如果您遇到这种情况:任何文件夹路径中都不要有空格!。严重地。事实上,从现在开始,您命名的任何内容都没有空格。这是我的控制台输出:(在/Users/*****/Desktop/LearningRuby/learn_ruby)$rake/Users/*******/Desktop/LearningRuby/learn_ruby/00_hello/hello_spec.rb:116:in`require':cannotloadsuchfile--hello(LoadError) 最佳

  6. ruby-on-rails - rspec should have_select ('cars' , :options => ['volvo' , 'saab' ] 不工作 - 2

    关闭。这个问题需要detailsorclarity.它目前不接受答案。想改进这个问题吗?通过editingthispost添加细节并澄清问题.关闭8年前。Improvethisquestion在首页我有:汽车:VolvoSaabMercedesAudistatic_pages_spec.rb中的测试代码:it"shouldhavetherightselect"dovisithome_pathit{shouldhave_select('cars',:options=>['volvo','saab','mercedes','audi'])}end响应是rspec./spec/request

  7. ruby-on-rails - s3_direct_upload 在生产服务器中不工作 - 2

    在Rails4.0.2中,我使用s3_direct_upload和aws-sdkgems直接为s3存储桶上传文件。在开发环境中它工作正常,但在生产环境中它会抛出如下错误,ActionView::Template::Error(noimplicitconversionofnilintoString)在View中,create_cv_url,:id=>"s3_uploader",:key=>"cv_uploads/{unique_id}/${filename}",:key_starts_with=>"cv_uploads/",:callback_param=>"cv[direct_uplo

  8. ruby - JetBrains RubyMine 3.2.4 调试器不工作 - 2

    使用Ruby1.9.2运行IDE提示说需要gemruby​​-debug-base19x并提供安装它。但是,在尝试安装它时会显示消息Failedtoinstallgems.Followinggemswerenotinstalled:C:/ProgramFiles(x86)/JetBrains/RubyMine3.2.4/rb/gems/ruby-debug-base19x-0.11.30.pre2.gem:Errorinstallingruby-debug-base19x-0.11.30.pre2.gem:The'linecache19'nativegemrequiresinstall

  9. ruby - `rescue $!` 是如何工作的? - 2

    我知道全局变量$!包含最新的异常对象,但我对下面的语法感到困惑。谁能帮助我理解以下语法?rescue$! 最佳答案 此构造可防止异常停止您的程序并使堆栈跟踪冒泡。它还会将该异常作为值返回,这很有用。a=get_me_datarescue$!在此行之后,a将保存请求的数据或异常。然后您可以分析该异常并采取相应措施。defget_me_dataraise'Nodataforyou'enda=get_me_datarescue$!puts"Executioncarrieson"pa#>>Executioncarrieson#>>#更现实的

  10. ruby - File.read ("| echo mystring") 是如何工作的? - 2

    我在我正在处理的一些代码中发现了这一点。它旨在解决从磁盘读取key文件的要求。在生产环境中,key文件的内容位于环境变量中。旧代码:key=File.read('path/to/key.pem')新代码:key=File.read('|echo$KEY_VARIABLE')这是如何工作的? 最佳答案 来自IOdocs:Astringstartingwith“|”indicatesasubprocess.Theremainderofthestringfollowingthe“|”isinvokedasaprocesswithappro

随机推荐