Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sudo apt-get install mysql-server-4.1 mysql-common-4.1 \
- mysql-client-4.1 libmysqlclient14-dev libmysqlclient14 \
- mytop zlib1g-dev
- ruby --version
- ruby 1.8.5 (2006-08-25) [i486-linux]
- sudo apt-get install libmysql-ruby1.8
- echo "require 'mysql'" | irb
- require 'mysql'
- true
- irb
- irb(main):002:0> require 'mysql'
- => true
- irb(main):003:0> conn = Mysql.connect 'localhost','myusername','mypassword'
- => #<Mysql:0xb7f26c5c>
- irb(main):004:0> conn.server_info
- => "4.1.11-Debian_4sarge7-log"
- irb(main):006:0> conn.list_dbs
- => ["testapp_dev", "testapp_production", "testapp_test", "mysql", "test"]
- irb(main):007:0> conn.ping
- => #<Mysql:0xb7f26c5c>
- irb(main):008:0> conn.select_db 'testapp_production'
- => #<Mysql:0xb7f26c5c>
- irb(main):009:0> conn.list_tables
- => []
- irb(main):010:0> conn.stat
- => "Uptime: 51776 Threads: 1 Questions: 35 Slow queries: 0 Opens: 26 Flush tables: 1 Open tables: 15 Queries per second avg: 0.001"
- irb(main):011:0>
- script/console
- Loading development environment.
- ./script/../config/../config/../vendor/rails/activerecord/lib/active_record/
- connection_adapters/mysql_adapter.rb:6:in `define_all_hashes_method!':
- RuntimeError: Mysql not loaded
- >>
- #database.yml
- #development:
- # adapter: mysql
- # database: testapp_dev
- # host: localhost
- # encoding: utf8
- # username: myusername
- # password: mypassword
- #
- #test:
- # adapter: mysql
- # database: testapp_test
- # host: localhost
- # encoding: utf8
- # username: myusername
- # password: mypassword
- #
- #production:
- # adapter: mysql
- # database: testapp_production
- # host: localhost
- # encoding: utf8
- # username: myusername
- # password: mypassword
- Looking at:
- less vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
- require 'active_record/connection_adapters/abstract_adapter'
- module MysqlCompat
- # add all_hashes method to standard mysql-c bindings or pure ruby version
- def self.define_all_hashes_method!
- raise 'Mysql not loaded' unless defined?(::Mysql::Result)
- ...
- then back in irb:
- irb
- irb(main):001:0> require 'mysql'
- => true
- irb(main):002:0> puts "true" if defined? ::Mysql::Result
- => nil
- irb(main):003:0> puts "true" if defined? ::Mysql
- true
- => nil
- irb(main):004:0> puts "true" if defined? ::Mysql::Result
- => nil
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement