---
title: "Could not load 'active_record/connection_adapters/mysql2_adapter'"
author: "samwalt"
date: "2017-10-14T21:37:56Z"
tags: []
categories: ["编程语言"]
slug: "could-not-load-active-record-connection-adapters-mysql2-adapter"
draft: false
lastmod: "2017-10-14T21:38:19Z"
id: 2396334
url: "https://samwalt.iteye.com/blog/2396334"
---

运行　
```ruby
rake db:migrate
```

报如下错误：


```shell
LoadError: Could not load 'active_record/connection_adapters/mysql2_adapter'. Make sure that the adapter in config/database.yml is valid. If you use an adapter other than 'mysql2', 'postgresql' or 'sqlite3' add the necessary adapter gem to the Gemfile.

LoadError: libmysqlclient.so.18: cannot open shared object file: No such file or directory - /home/drjr/opt/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/mysql2-0.4.5/lib/mysql2/mysql2.so
```


原因是mysql从5.6升级到5.7了，mysql2这个gem的版本是0.4.3，有点老了，不能支持mysql5.7。mysql2升级到0.4.9，就OK了。