title: El Capitan upgrade: Library not loaded: /usr/local/lib/libmysqlclient.18.dylib
body: <p>Error:</p>
  
  <pre><code>/Users/askar/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/mysql2-0.3.20/lib/mysql2.rb:31:in `require': dlopen(/Users/askar/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-14/2.2.0-static/mysql2-0.3.20/mysql2/mysql2.bundle, 9): Library not loaded: /usr/local/lib/libmysqlclient.18.dylib (LoadError)
    Referenced from: /Users/askar/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-14/2.2.0-static/mysql2-0.3.20/mysql2/mysql2.bundle
    Reason: image not found - /Users/askar/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-14/2.2.0-static/mysql2-0.3.20/mysql2/mysql2.bundle
  </code></pre>
  
  <p>In Gemfile: <code>gem 'mysql2'</code></p>
  
  <p><strong>$ ls -al /usr/local/lib/libmysql*</strong></p>
  
  <pre><code>lrwxr-xr-x  1 askar  admin  49 Nov 13 10:48 /usr/local/lib/libmysqlclient.20.dylib -&gt; ../Cellar/mysql/5.7.9/lib/libmysqlclient.20.dylib
  lrwxr-xr-x  1 askar  admin  42 Nov 13 10:48 /usr/local/lib/libmysqlclient.a -&gt; ../Cellar/mysql/5.7.9/lib/libmysqlclient.a
  lrwxr-xr-x  1 askar  admin  46 Nov 13 10:48 /usr/local/lib/libmysqlclient.dylib -&gt; ../Cellar/mysql/5.7.9/lib/libmysqlclient.dylib
  lrwxr-xr-x  1 askar  admin  37 Nov 13 10:48 /usr/local/lib/libmysqld.a -&gt; ../Cellar/mysql/5.7.9/lib/libmysqld.a
  lrwxr-xr-x  1 askar  admin  44 Nov 13 10:48 /usr/local/lib/libmysqlservices.a -&gt; ../Cellar/mysql/5.7.9/lib/libmysqlservices.a
  </code></pre>
  
  <p><strong>$ ls -al /usr/local/Cellar/mysql/5.7.9/lib/</strong></p>
  
  <pre><code>total 84392
  drwxr-xr-x   9 askar  admin       306 Nov 12 22:16 .
  drwxr-xr-x  14 askar  admin       476 Nov 13 10:48 ..
  -r--r--r--   1 askar  admin   3780168 Nov 13 10:48 libmysqlclient.20.dylib
  -r--r--r--   1 askar  admin   4280752 Nov 12 22:16 libmysqlclient.a
  lrwxr-xr-x   1 askar  admin        23 Nov 12 22:16 libmysqlclient.dylib -&gt; libmysqlclient.20.dylib
  -r--r--r--   1 askar  admin  35126528 Nov 12 22:16 libmysqld.a
  -r--r--r--   1 askar  admin      9048 Nov 12 22:16 libmysqlservices.a
  drwxr-xr-x   3 askar  admin       102 Nov 13 10:48 pkgconfig
  drwxr-xr-x  43 askar  admin      1462 Nov 12 22:17 plugin
  drwxr-xr-x  43 askar  admin      1462 Nov 12 22:17 plugin
  </code></pre>
  
  <p>As you see I'm having <code>libmysqlclient.20.dylib</code>, it's <code>20</code> not <code>18</code>, otherwise I'd follow the solution <a href="https://stackoverflow.com/a/18465283/1745902">here</a>.</p>
  
  <p>I've recently upgraded to El Capitan but not sure it that's the cause.</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>Thanks to @Rashmirathi for the hint to re-install the gem.</p>
  
  <p>Just wanted to note, I needed also to specify in Gemfile as:</p>
  
  <pre><code>gem 'mysql2', '~&gt; 0.3.18'
  </code></pre>
  
  <p>Otherwise I had error:</p>
  
  <blockquote>
    <p>Specified 'mysql2' for database adapter, but the gem is not loaded. Add <code>gem 'mysql2'</code> to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).</p>
  </blockquote>
  
  <p>But finally I got error:</p>
  
  <blockquote>
    <p>Mysql2::Error<br>
        Your password has expired. To log in you must change it using a client that supports expired passwords.</p>
  </blockquote>
  
  <p>Which is solved by setting up a password again:</p>
  
  <pre><code>SET PASSWORD=PASSWORD('your_password');
  </code></pre>