【问题标题】:Sequel::AdapterNotFound: LoadError: cannot load such file -- mysqlSequel::AdapterNotFound: LoadError: cannot load such file -- mysql
【发布时间】:2023-04-10 07:48:01
【问题描述】:

当我尝试使用命令提示符迁移文件时: sequel -m db/migrations/ mysql://root:root@localhost/todo 我收到以下错误:

错误:Sequel::AdapterNotFound: LoadError: cannot load such file -- mysql C:/Ruby24-x64/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `需要'

以下是我在 db/migrations 中的迁移文件:

    Sequel.migration do
     change do
        create_table :users do
        primary_key :id
        String :name, :unique => true, :length => 32, :null => false
        String :password, :length => 32, :null => false
        DateTime :created_at
     end
   end
end 

我的宝石文件:

>     GEM   remote: https://rubygems.org/   specs:
>     rack (2.0.3)
>     rack-protection (2.0.0)
>       rack
>     sinatra (2.0.0)
>       rack (~> 1.4)
>       rack-protection (~> 1.4)
>       tilt (~> 1.3, >= 1.3.4)
>     tilt (2.0.7)
> 
> PLATFORMS   x64-mingw32
> 
> DEPENDENCIES   bundler (= 1.15.1)   sinatra (= 2.0.0)
> 
> BUNDLED WITH
>    1.15.1

【问题讨论】:

    标签: mysql ruby database sinatra sequel


    【解决方案1】:

    您必须使用mysql2 适配器作为连接字符串。这也意味着你必须在你的机器上安装mysql2 gem。确保你的机器上有 MySQL 开发包并构建必需品,因为这个 gem 是一个原生扩展,并且在 Ruby 之外具有依赖项。

    然后通过以下方式连接:

    sequel -m db/migrations/ mysql2://root:root@localhost/todo
    

    【讨论】:

      猜你喜欢
      • 2016-10-13
      • 1970-01-01
      • 2014-03-08
      • 2022-01-21
      • 1970-01-01
      • 2023-03-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多