title: How to connect to MySQL from ruby
body: <p>I am trying to take a Mysql Instance. But getting error. here is the code i am trying with :</p>
  
  <h2>Code  :</h2>
  
  <pre><code> require "mysql"
  
  begin
  #con = Mysql.new '127.0.0.1', 'root', '', 'amazon'
  con = Mysql.new("localhost", "root", '', "amazon")
  
  rs = con.query("SELECT * FROM url")
  
  rs.each do |row|
  puts row.join("\s")
  end
  
   rescue Mysql::Error =&gt; e
   puts e.errno
   puts e.error
   ensure
   con.close if con
   end
  </code></pre>
  
  <h2>ERROR :</h2>
  
  <pre><code>   in `rescue in &lt;top (required)&gt;': uninitialized constant Mysql (NameError)
  </code></pre>