title: Ruby on Rails - cannot load such file -- mysql2/2.2/mysql2 (LoadError)
body: <p>I was using SQLite for my Rails project but when I heard that Heroku doesn't support SQLite, I switched to MYSQL.</p>
  
  <p>After switching my database, I started my rails server "rails s" but it gives me the following error:</p>
  
  <pre><code>    C:\Sites\simple_cms&gt;rails server
  C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mysql2-0.3.18-x64-mingw32/lib/mysql2/mysql2.rb:2:in `require'
  : cannot load such file -- mysql2/2.2/mysql2 (LoadError)
          from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mysql2-0.3.18-x64-mingw32/lib/mysql2/mysql2.rb:2
  :in `&lt;top (required)&gt;'
          from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mysql2-0.3.18-x64-mingw32/lib/mysql2.rb:31:in `r
  equire'
          from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mysql2-0.3.18-x64-mingw32/lib/mysql2.rb:31:in `&lt;
  top (required)&gt;'
          from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.8.4/lib/bundler/runtime.rb:76:in `requ
  ire'
          from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.8.4/lib/bundler/runtime.rb:76:in `bloc
  k (2 levels) in require'
          from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.8.4/lib/bundler/runtime.rb:72:in `each
  '
          from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.8.4/lib/bundler/runtime.rb:72:in `bloc
  k in require'
          from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.8.4/lib/bundler/runtime.rb:61:in `each
  '
          from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.8.4/lib/bundler/runtime.rb:61:in `requ
  ire'
          from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.8.4/lib/bundler.rb:134:in `require'
          from C:/Sites/simple_cms/config/application.rb:7:in `&lt;top (required)&gt;'
          from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks
  .rb:78:in `require'
          from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks
  .rb:78:in `block in server'
          from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks
  .rb:75:in `tap'
          from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks
  .rb:75:in `server'
          from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks
  .rb:39:in `run_command!'
          from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.0/lib/rails/commands.rb:17:in `&lt;top
   (required)&gt;'
          from bin/rails:4:in `require'
          from bin/rails:4:in `&lt;main&gt;'
  </code></pre>
  
  <p>This is my gemfile:</p>
  
  <pre><code># Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
  gem 'rails', '4.2.0'
  # Use mysql as the database for Active Record
  gem 'mysql2'
  </code></pre>
  
  <p>I searched thoroughly, found some answers but it didn't work.</p>
  
  <p>I pasted my <code>libmysql.dll</code> file from <code>Program Files/MySQL Server 5.6</code> to <code>Ruby/bin</code> but still no luck. I performed the following commands:</p>
  
  <pre><code>gem uninstall mysql2
  
  gem install mysql2 --platform=ruby
  </code></pre>
  
  <p>I followed this tutorial and still got the same error: <a href="https://stackoverflow.com/questions/15604058/error-cannot-load-such-file-mysql2-2-0-mysql2-loaderror-on-windows-xp">Error &quot;...cannot load such file -- mysql2/2.0/mysql2 (LoadError)&quot;. On Windows XP with Ruby 2.0.0</a></p>
  
  <p>I will highly appreciate it if someone will help me out, so that I can deploy it to Heroku.</p>
  
  <p>Thanks.</p>