linux下Ruby怎么连接MySQL

linux下Ruby怎么连接MySQL,第1张

配置 database.yml 文件

development:

adapter: mysql2

encoding: utf8 (字符集)

database: database_name×××(数据库名)

username: root (用户名)

password: ××××××(用户密码)

host: localhost

pool: 5 (连接池数量)

timeout: 5000 (超时时间)

make的时候需要调用ruby很多编译前的参数.一些信息make不知道的话会不知道如何建库.

我个人的建议是根据你安装的ruby路径和版本信息把配置选项补充全.下面是我电脑上面的配置,你可以借鉴一下.据我分析应该能解决你的问题.

Provided configuration options:

--with-opt-dir

--with-opt-include

--without-opt-include=${opt-dir}/include

--with-opt-lib

--without-opt-lib=${opt-dir}/usr/lib

--with-make-prog

--without-make-prog

--srcdir=.

--curdir

--ruby=/usr/local/ruby-2.1.2/rubies/ruby-2.1.2/bin/ruby

首先用一个在Rails开发中一定会遇到的YAML文件——database.yml——作为示例。在你创建一个Rails工程后,Rails会自动给你创建一个这样的文件,它的路径是config/database.yml:

# MySQL (default setup). Versions 4.1 and 5.0 are recommended.

# 此处省略一些注释。

development:

adapter: mysql

database: demo_development

username: root

password:

host: localhost

# 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:

adapter: mysql

database: demo_test

username: root

password:

host: localhost

production:

adapter: mysql

database: demo_production

username: root

password:

host: localhost


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/8663720.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-19
下一篇 2023-04-19

发表评论

登录后才能评论

评论列表(0条)

保存