Ruby连接Mysql数据库
已经尝试连接Mysql数据库好久了,都没有连接成功.
Mac OS 10.5.2,
Mysql 5.0.45
Ruby 1.8.6
下载了ruby-dbi
按照Readme上面的方法,已经显示安装成功了
Brinados-iMac:ruby-dbi brinado$ ruby setup.rb config --with=dbi,dbd_mysql
entering config phase...
config done.
Brinados-iMac:ruby-dbi brinado$ ruby setup.rb setup
entering setup phase...
setting #! line to "#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby"
setup.rb: skip bin/proxyserver(dbd_proxy) by user option
setup.rb: skip ext/dbd_sqlite(dbd_sqlite) by user option
setup.rb: skip ext/dbd_sybase(dbd_sybase) by user option
setup done.
Brinados-iMac:ruby-dbi brinado$ sudo ruby setup.rb install
Password:
entering install phase...
mkdir -p /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin
install sqlsh.rb /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin
setup.rb: skip bin/proxyserver(dbd_proxy) by user option
mkdir -p /Library/Ruby/Site/1.8/DBD/Mysql
install Mysql.rb /Library/Ruby/Site/1.8/DBD/Mysql/Mysql.rb
mkdir -p /Library/Ruby/Site/1.8/dbi
install columninfo.rb /Library/Ruby/Site/1.8/dbi
install row.rb /Library/Ruby/Site/1.8/dbi
install sql.rb /Library/Ruby/Site/1.8/dbi
install trace.rb /Library/Ruby/Site/1.8/dbi
install utils.rb /Library/Ruby/Site/1.8/dbi
install version.rb /Library/Ruby/Site/1.8/dbi
install dbi.rb /Library/Ruby/Site/1.8
setup.rb: skip ext/dbd_sqlite(dbd_sqlite) by user option
setup.rb: skip ext/dbd_sybase(dbd_sybase) by user option
install done.在运行很简单的测试文件时提出了错误,
RubyMate r8136 running Ruby r1.8.6 (/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby)
>>> basic_figure.rb
DBI::InterfaceError: Could not load driver (no such file to load — mysql)
method load_driver in dbi.rb at line 344
method _get_full_driver in dbi.rb at line 227
method connect in dbi.rb at line 213
at top level in basic_figure.rb at line 3
Program exited.后来又尝试安装mysql-ruby-2.7.5,总是提示说
can't find header files for ruby.Ruby连接Mysql数据库应该是很主流的阿,为什么这样费劲呢?[img]../../../images/smiles/icon_twisted.gif" alt="[/img]
不知道我的问题在哪里?希望得到大家帮助!
P.S. 如何安装ruby-devel? 安装又出现错误~~
Brinados-iMac:~ brinado$ gem install ruby-devel
ERROR: could not find ruby-devel locally or in a repository