# Installing mysql2 Gem for Flarum Import

**URL:** https://meta.discourse.org/t/installing-mysql2-gem-for-flarum-import/317365
**Category:** Migration
**Created:** [July 20, 2024, 11:35am UTC](https://meta.discourse.org/t/installing-mysql2-gem-for-flarum-import/317365 "2024-07-20T11:35:35Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![ddeveloper](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ddeveloper/32/333791_2.png) [@ddeveloper](https://meta.discourse.org/u/ddeveloper)
#### Post date: [July 20, 2024, 11:35am UTC](https://meta.discourse.org/t/installing-mysql2-gem-for-flarum-import/317365/1 "2024-07-20T11:35:35Z")

</div>

I’ve no knowledge of Rails and hence, none that of discourse. I’m trying to migrate flarum database to discourse.

P.S: I’ve successfully installed discourse for production.

Right now, I’ve installed discourse docker from official git repository. When I try to run the import script in docker container:

```plaintext
su discourse -c 'bundle exec ruby script/import_scripts/flarum_import.rb'

```

I get this error:

```plaintext
/usr/local/lib/ruby/3.3.0/bundled_gems.rb:74:in `require': cannot load such file -- mysql2 (LoadError)
from /usr/local/lib/ruby/3.3.0/bundled_gems.rb:74:in `block (2 levels) in replace_require'

```

I’ve tried all methods explained in different forum posts but none worked.  
If anyone could explain in 2-3 steps what to do to run ‘flarum\_import.rb’ import script, that’d be a great help.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [July 20, 2024, 6:00pm UTC](https://meta.discourse.org/t/installing-mysql2-gem-for-flarum-import/317365/2 "2024-07-20T18:00:16Z")

</div>

If you look in /var/discourse/templates/import there are some examples of how to include the mysql stuff.

You also need to install mysql somewhere that Discourse can access it

---

<div class="post-metadata">

### Author: ![ddeveloper](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ddeveloper/32/333791_2.png) [@ddeveloper](https://meta.discourse.org/u/ddeveloper)
#### Post date: [July 23, 2024, 3:49pm UTC](https://meta.discourse.org/t/installing-mysql2-gem-for-flarum-import/317365/3 "2024-07-23T15:49:16Z")

</div>

> [@pfaffman](#):
>
> If you look in /var/discourse/templates/import there are some examples of how to include the mysql stuff.

Thanks for pointing out. I just didn’t know how to execute those scripts. Although, I’m not good at getting hints but this helped me in getting things straight.

I edited the “containers/app.yml”

```plaintext
cd /var/discourse/containers
sudo nano app.yml

```

And added the template path for mysql-dep template: `- "templates/import/mysql-dep.template.yml"` as shown below

 ![discourse_reply1](https://global.discourse-cdn.com/meta/original/4X/6/2/7/627890c3312f8978c279700a316a20d568489684.png)

After that, just rebuilt the app and all dependencies required for `flarum_import.rb` were installed.

Worked like a charm!

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [December 18, 2025, 11:20am UTC](https://meta.discourse.org/t/installing-mysql2-gem-for-flarum-import/317365/4 "2025-12-18T11:20:12Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
