Prerequisites
The Ruby DBI module includes the code that implements the general DBI layer, as well as a set of DBD-level drivers. Many of these drivers require that you have additional software installed. For example, the database driver for MySQL is written in Ruby and provides a binding to the Ruby MySQL module, which itself is written in C and provides a binding to the MySQL C client API. This means that if you want to write DBI scripts to access MySQL databases, you'll need to have both the Ruby MySQL module and the C API installed. For further information on the Ruby MySQL module, see the document referenced in the "Resources" section. Here, I assume that the MySQL module is installed and available for use by DBI.
Installation
After you have satisfied the prerequisites described in the previous section, you can install the Ruby DBI module, which can be obtained from the following site:
http://rubyforge.org/projects/ruby-dbi/The DBI module is distributed as a compressed tar file, which you should unpack after downloading it. For example, if the current version is 0.1.1, the distribution file can be unpacked using either of the following commands:
% tar zxf dbi-0.1.1.tar.gzAfter unpacking the distribution, change location into its top-level directory and configure it using the setup.rb script in that directory. The most general configuration command looks like this, with no arguments following the config argument:
% gunzip < dbi-0.1.1.tar.gz | tar xf -
% ruby setup.rb configThat command configures the distribution to install all drivers by default. To be more specific, provide a --with option that lists the particular parts of the distribution you want to use. For example, to configure only the main DBI module and the MySQL DBD-level driver, issue the following command:
% ruby setup.rb config --with=dbi,dbd_mysqlAfter configuring the distribution, build and install it:
% ruby setup.rb setupYou might need to run the installation command as root.
% ruby setup.rb install
The rest of this document uses the following notational conventions:
- "DBI module" refers collectively to the DBI layer as well as the DBD-level drivers, unless context indicates that only the database independent layer is meant.
- "DBD::Mysql" refers to the MySQL-specific database driver for DBI.
- "Ruby MySQL module" refers to the module on which DBD::Mysql is built (that is, the module that provides the bindings to the MySQL C client library).
在整个操作的过程中
ruby setup.rb config --with=dbi,dbd_mysql这句话是主要的问题,以前就是把这个选项搞错了
中间搜索到了很多有用的网站
http://www.kitebird.com/articles/ruby-mysql.html 这篇文章的主要引用,里面有一篇 Migrating from IIS to Apache 要看一下
http://www.rubyonrailsblog.com/articles/2006/09/04/installing-ruby-ruby-on-rails-mysql-and-rmagick-on-windows
这个里面提到了 Ruby, Ruby on Rails, MySQL and Rmagick on Windows
http://www.troubleshooters.com/codecorn/ruby/database/index.htm 里面有比较全的ruby数据库连接的信息
http://willh.org/~cfc/wiki/index.php/Ruby%E5%92%8C%E8%B3%87%E6%96%99%E5%BA%AB 这个网站不知道是干嘛的,不过提到了 DBI(database interface)
http://sqlrelay.sourceforge.net/sqlrelay/programming/rubydbi.html 里面有比较全的关于dbi的使用(
Programming with SQL Relay using the Ruby DBI API)http://del.icio.us/里搜索到了,这个网站不错