Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8089299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:21:19+00:00 2026-06-05T19:21:19+00:00

I have install the mysql gem but am falling at the first hurdle: initialize’:

  • 0

I have install the mysql gem but am falling at the first hurdle:

 initialize': wrong number of arguments(4 for 0) (ArgumentError)
 from open.rb:14:in `new' 
 from open.rb:14:in `<main>'

Is the result from this code:

 require 'mysql'

 db = Mysql.new('localhost','root','','test')
 puts db

I was following the code from this tutorial:

http://rubylearning.com/satishtalim/ruby_mysql_tutorial.html

It just looks like the new method is not going to accept 4 arguments. I have no idea why. Mysql.new creates a new object just fine.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T19:21:20+00:00Added an answer on June 5, 2026 at 7:21 pm

    Use the Mysql2 gem:

    gem install mysql2
    

    Then:

    require 'mysql2'
    client = Mysql2::Client.new(:host => "localhost", :username => "root")
    results = client.query("show databases")
    results.each do |row|
      puts row["Database"]
    end
    

    You can find more information in the gem documentation

    HTH!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have trouble installing the mysql gem: gem install mysql Fetching: mysql-2.8.1.gem (100%) Building
When trying to install the mysql gem from cPanel on my website, I get
standard is this: gem mysql, 2.7 but.. when I install this gem in the
So, I currently have to do this to install the mysql gem: export ARCHFLAGS=-arch
I already have a mysql server setup via MAMP. But when trying to install
i have install mysql to a windows pc (with ip 192.168.1.100) and i have
I have a local install of Apache / MySQL and PHP on Fedora Linux.
I am trying to install the InnoDb plugin for mysql 5.1.61, I have successfully
First I have install Mac 10.6.3 on my system now I want to install
I have RedHat v.6.2 server without internet access. I have install it yesterday, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.