zoukankan      html  css  js  c++  java
  • 06. rails gem 安装mysql

    修改Gamefile

    Gamefile 里添加 gem 'mysql2'

    执行命令行

    bundle

    可以看到下图片上已经安装好依赖了

    修改配置文件

    修改config/database.yml文件

    # SQLite. Versions 3.8.0 and up are supported.
    #   gem install sqlite3
    #
    #   Ensure the SQLite 3 gem is defined in your Gemfile
    #   gem 'sqlite3'
    #
    #default: &default
     # adapter: sqlite3
     # pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
     # timeout: 5000
    
    ##添加msyql的配置
    default: &default
      adapter: mysql2
      encoding: utf8mb4
      pool: 5
      host: 127.0.0.1
      username: root
      password: 123456
    
    
    development:
      <<: *default
      #database: db/development.sqlite3
      database: circles_development  #数据库的名称
    
    # Warning: The database defined as "test" will be erased and
    # re-generated from your development database when you run "rake".
    # Do not set this db to the same as development or production.
    test:
      <<: *default
      #database: db/test.sqlite3
      database: circles_test
    
    production:
      <<: *default
      #database: db/production.sqlite3
        database: circles_production
    

    查看rake使用命令

    rake -T #查看命令

    创建数据库

    haima@haima-PC:/media/haima/34E401CC64DD0E28/site/go/src/ruby/circles$ rake db:create
    Created database 'circles_development'
    Created database 'circles_test'
    

    下图可以看到已经创建了两个数据库

  • 相关阅读:
    url protocol
    wpf webbrowser取消js报错
    c#端口扫描器wpf+socket
    c#协变 抗变
    MTK刷机快捷键
    iTextCharp c#
    wince可用的7-zip
    直播平台搭建与相关资料
    pyinstall
    面向对象常见的术语
  • 原文地址:https://www.cnblogs.com/haima/p/14259449.html
Copyright © 2011-2022 走看看