# Migrating from mybb

**URL:** https://meta.discourse.org/t/migrating-from-mybb/25563
**Category:** Support
**Created:** [February 23, 2015, 11:12am UTC](https://meta.discourse.org/t/migrating-from-mybb/25563 "2015-02-23T11:12:46Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![dandv](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dandv/32/169779_2.png) [@dandv](https://meta.discourse.org/u/dandv)
#### Post date: [February 23, 2015, 11:12am UTC](https://meta.discourse.org/t/migrating-from-mybb/25563/1 "2015-02-23T11:12:46Z")

</div>

I’m trying to migrate a MyBB instance and haven’t found a walk-through, so hopefully this can become one.

I’m also new to Rails and Docker.

So far I’ve installed the Discourse Docker image, launched a local MySQL server and populated it with the data from MyBB.

The [migration script](https://github.com/discourse/discourse/blob/master/script/import_scripts/mybb.rb) only says it should be called like this:

```
RAILS_ENV=production bundle exec ruby script/import_scripts/mybb.rb

```

That assumes you have cloned the discourse repo itself (not the Docker). So you have to first

```
mkdir /var/discourse.src
git clone https://github.com/discourse/discourse.git /var/discourse.src
cd /var/discourse.src

```

You also need to run

```
apt-get install bundler

```

After that, I’m out of my depth. `bundle install` says “You are running an old version of bundler, please update by running: gem install bundler” but after I run `gem install bundler` (which gets bundler-1.8.2) and re-run `bundle install`, I get the same warning.

Anyway, the blocker is

```
Gem::InstallError: better_errors requires Ruby version >= 2.0.0.

```

Do I just go ahead and [install Ruby 2.1.5](https://gorails.com/setup/ubuntu/14.04)? How do I do that inside the Docker container? Is Discourse compatible with Ruby 2? If so, should the Docker image be updated?

I gave a try to installing Ruby 2.1.5, but I still get the error about Ruby \>= 2.0.0. being required:

```plaintext
root@...:/var/discosrc# RAILS_ENV=production bundle exec ruby script/import_scripts/mybb.rb
Could not find rake-10.4.2 in any of the sources
Run `bundle install` to install missing gems.
root@...:/var/discosrc# bundle install
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this application for all non-root users on this machine.
Fetching gem metadata from https://rubygems.org/.......
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies...
Using rake 10.4.2
Using 6to5-source 3.3.7
Using execjs 2.2.2
Using 6to5 0.5.0
Using CFPropertyList 2.2.8
Using i18n 0.6.11
Using json 1.8.2
Using minitest 5.5.1
Using thread_safe 0.3.4
Using tzinfo 1.2.2
Using activesupport 4.1.8
Using builder 3.2.2
Using erubis 2.7.0
Using actionview 4.1.8
Using rack 1.5.2
Using rack-test 0.6.2
Using actionpack 4.1.8
Using mime-types 1.25.1
Using polyglot 0.3.5
Using treetop 1.4.15
Using mail 2.5.4
Using actionmailer 4.1.8
Using actionpack-action_caching 1.1.1
Using activemodel 4.1.8
Using active_model_serializers 0.8.2
Using arel 5.0.1.20140414130214
Using activerecord 4.1.8
Using annotate 2.6.5
Using handlebars-source 2.0.0
Using ember-source 1.9.0.beta.4
Using barber 0.5.0
Using coderay 1.1.0

Gem::InstallError: better_errors requires Ruby version >= 2.0.0.
An error occurred while installing better_errors (2.1.1), and Bundler cannot continue.
Make sure that `gem install better_errors -v '2.1.1'` succeeds before bundling.

```

PS: no “migration” tag?

---

<div class="post-metadata">

### Author: ![elberet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elberet/32/122404_2.png) [@elberet](https://meta.discourse.org/u/elberet)
#### Post date: [February 23, 2015, 12:40pm UTC](https://meta.discourse.org/t/migrating-from-mybb/25563/2 "2015-02-23T12:40:20Z")

</div>

I would generally recommend to run the importer in development mode, export the result as a backup and restore that into the production instance. If that is not an option for you, try this:

- Connect to your server, become `root` (if you’ve connected as a regular user) and `cd /var/discourse`
- SSH into or enter the running production container: `./launcher ssh app` or `./launcher enter app`.
- Become the discourse user: `su - discourse`
- Install the MySQL client gem: `gem install mysql2`
- Open the import script in an editor and fill in your old forum’s MySQL server address: `cd /var/www/discourse/script/import_scripts && nano mybb.rb`
- (You will most likely have to change your old server’s configuration or firewall to gain access to your MySQL server; if that isn’t possible, you may have to install MySQL inside the container and import a dump of the mybb database.)
- Run the importer: `ruby mybb.rb`

If everything worked, rebuild your production container to get rid of the MySQL server, gem and modifications to `mybb.rb`.

---

<div class="post-metadata">

### Author: ![dandv](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dandv/32/169779_2.png) [@dandv](https://meta.discourse.org/u/dandv)
#### Post date: [March 12, 2015, 6:34am UTC](https://meta.discourse.org/t/migrating-from-mybb/25563/3 "2015-03-12T06:34:13Z")

</div>

How can I run the importer in “development mode”?

The MyBB forum runs on a separate machine. I cloned the Discourse repo on that machine, changed the MySQL login details in `mybb.rb` and tried to run `RAILS_ENV=production bundle exec ruby script/import_scripts/mybb.rb`. It failed with:

```plaintext
/home/dan/discourse/Gemfile:92:in `evaluate': compile error (SyntaxError)
/home/dan/discourse/Gemfile:72: syntax error, unexpected ':', expecting kEND
  gem 'arel', git: 'https://github.com/rails/arel.git'
                  ^
/home/dan/discourse/Gemfile:73: syntax error, unexpected ':', expecting kEND
  gem 'rails', git: 'https://github.com/rails/rails.git'
                   ^
/home/dan/discourse/Gemfile:74: syntax error, unexpected ':', expecting kEND
  gem 'rails-observers', git: 'https://github.com/SamSaffro...
                             ^
/home/dan/discourse/Gemfile:75: syntax error, unexpected ':', expecting kEND
  gem 'seed-fu', git: 'https://github.com/SamSaffro...
                     ^
/home/dan/discourse/Gemfile:75: syntax error, unexpected ',', expecting kEND
...b.com/SamSaffron/seed-fu.git', branch: 'discourse'
                              ^
/home/dan/discourse/Gemfile:92: syntax error, unexpected ':', expecting $end
gem 'redis', require: ["redis", "redis/connection/hiredis"]
                     ^
        from /usr/lib/ruby/vendor_ruby/bundler/definition.rb:17:in `build'
        from /usr/lib/ruby/vendor_ruby/bundler.rb:136:in `definition'
        from /usr/lib/ruby/vendor_ruby/bundler.rb:124:in `load'
        from /usr/lib/ruby/vendor_ruby/bundler.rb:107:in `setup'
        from /usr/lib/ruby/vendor_ruby/bundler/cli.rb:342:in `exec'
        from /usr/lib/ruby/vendor_ruby/bundler/vendor/thor/task.rb:22:in `send'
        from /usr/lib/ruby/vendor_ruby/bundler/vendor/thor/task.rb:22:in `run'
        from /usr/lib/ruby/vendor_ruby/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
        from /usr/lib/ruby/vendor_ruby/bundler/vendor/thor.rb:246:in `dispatch'
        from /usr/lib/ruby/vendor_ruby/bundler/vendor/thor/base.rb:389:in `start'
        from /usr/bin/bundle:13

```

These syntax errors suggest that `bundle` was the wrong executable. I ran `sudo gem install bundler`, which fixed the problem. Then,

```sh
RAILS_ENV=production bundle exec ruby script/import_scripts/mybb.rb
Could not find pg-0.18.1 in any of the sources
Run `bundle install` to install missing gems.

```

Alright,

```plaintext
$ bundle install
Fetching gem metadata from https://rubygems.org/.......
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Using rake 10.4.2
Using CFPropertyList 2.2.8
Using i18n 0.7.0
Using json 1.8.2
Using minitest 5.5.1
Using thread_safe 0.3.4
Using tzinfo 1.2.2
Using activesupport 4.1.9
Using builder 3.2.2
Using erubis 2.7.0
Using actionview 4.1.9
Using rack 1.5.2
Using rack-test 0.6.3
Using actionpack 4.1.9
Using mime-types 1.25.1
Using polyglot 0.3.5
Using treetop 1.4.15
Using mail 2.5.4
Using actionmailer 4.1.9
Using actionpack-action_caching 1.1.1
Using activemodel 4.1.9
Using active_model_serializers 0.8.2
Using arel 5.0.1.20140414130214
Using activerecord 4.1.9
Using annotate 2.6.6
Using babel-source 4.6.6
Using execjs 2.4.0
Using babel-transpiler 0.6.0
Using handlebars-source 2.0.0
Using ember-source 1.9.0.beta.4
Using barber 0.5.0
Using coderay 1.1.0
Using better_errors 2.1.1
Using debug_inspector 0.0.2
Using binding_of_caller 0.7.2
Using hitimes 1.2.2
Using timers 4.0.1
Using celluloid 0.16.0
Using certified 1.0.0
Using connection_pool 2.1.2
Using crass 1.0.1
Using daemons 1.1.9
Using diff-lcs 1.2.5
Using docile 1.1.5
Using dotenv 1.0.2
Using email_reply_parser 0.5.8
Using ember-data-source 0.14
Using thor 0.19.1
Using railties 4.1.9
Using jquery-rails 3.1.2
Using ember-rails 0.14.1
Using eventmachine 1.0.7
Using excon 0.44.4
Using exifr 1.1.3
Using fabrication 2.9.8
Using fakeweb 1.3.0
Using multipart-post 2.0.0
Using faraday 0.9.1
Using fast_blank 0.0.2
Using rake-compiler 0.9.4
Using fast_stack 0.1.0
Using fast_xor 1.1.3
Using fast_xs 0.8.0
Using fastimage_discourse 1.6.6
Using ffi 1.9.6
Using fission 0.5.0
Using flamegraph 0.1.0
Using formatador 0.2.5
Using net-ssh 2.9.2
Using net-scp 1.2.1
Using fog-core 1.27.2
Using mini_portile 0.6.2
Using nokogiri 1.6.6.2
Using fog-xml 0.1.1
Using fog-atmos 0.1.0
Using multi_json 1.10.1
Using fog-json 1.0.0
Using inflecto 0.0.2
Using fog-brightbox 0.7.1
Using fog-ecloud 0.0.2
Using fog-profitbricks 0.0.1
Using fog-radosgw 0.0.3
Using fog-sakuracloud 0.1.1
Using fog-softlayer 0.3.26
Using fog-storm_on_demand 0.1.0
Using fog-terremark 0.0.3
Using fog-vmfusion 0.0.1
Using fog-voxel 0.0.2
Using ipaddress 0.8.0
Using fog 1.26.0
Using foreman 0.77.0
Using fspath 2.0.6
Using sorcerer 1.0.2
Using given_core 3.5.4
Using guess_html_encoding 0.0.11
Using hashie 3.4.0
Using highline 1.7.1
Using hike 1.2.3
Using hiredis 0.6.0
Using htmlentities 4.3.3
Using image_size 1.1.5
Using in_threads 1.2.2
Using progress 3.0.2
Using image_optim 0.9.1
Using jwt 1.3.0
Using kgio 2.9.3
Using librarian 0.1.2
Using libv8 3.16.14.7
Using listen 0.7.3
Using logster 0.1.8
Using lru_redux 0.8.4
Using redis 3.2.1
Using message_bus 1.0.6
Using metaclass 0.0.4
Using method_source 0.8.2
Using mocha 1.1.0
Using mock_redis 0.14.0
Using moneta 0.8.0
Using msgpack 0.5.11
Using multi_xml 0.5.5
Using mustache 0.99.8
Using netrc 0.10.3
Using nokogumbo 1.2.0
Using oauth 0.4.7
Using oauth2 1.0.0
Using oj 2.12.0
Using omniauth 1.2.2
Using omniauth-oauth2 1.2.0
Using omniauth-facebook 2.0.0
Using omniauth-github-discourse 1.1.2
Using omniauth-google-oauth2 0.2.5
Using omniauth-oauth 1.0.1
Using ruby-openid 2.5.0
Using rack-openid 1.3.1
Using omniauth-openid 1.0.1
Using omniauth-twitter 1.0.1
Using onebox 1.5.13
Using openid-redis-store 0.0.2

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /usr/local/bin/ruby -r ./siteconf20150312-9260-1dzgbkw.rb extconf.rb
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
 --with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
***extconf.rb failed***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=/usr/local/bin/$(RUBY_BASE_NAME)
        --with-pg
        --without-pg
        --enable-windows-cross
        --disable-windows-cross
        --with-pg-config
        --without-pg-config
        --with-pg_config
        --without-pg_config
        --with-pg-dir
        --without-pg-dir
        --with-pg-include
        --without-pg-include=${pg-dir}/include
        --with-pg-lib
        --without-pg-lib=${pg-dir}/lib

extconf failed, exit code 1

Gem files will remain installed in /tmp/bundler20150312-9260-osxjxp/pg-0.18.1/gems/pg-0.18.1 for inspection.
Results logged to /tmp/bundler20150312-9260-osxjxp/pg-0.18.1/extensions/x86_64-linux/2.2.0-static/pg-0.18.1/gem_make.out
An error occurred while installing pg (0.18.1), and Bundler cannot continue.
Make sure that `gem install pg -v '0.18.1'` succeeds before bundling.

```

**Stuck**.

I also tried the second option you mentioned, but couldn’t install the `mysql2` gem:

```plaintext
root@li895-63-app:~# su - discourse
discourse@li895-63-app:~$ gem install mysql2
Fetching: mysql2-0.3.18.gem (100%)
ERROR: While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /usr/local/lib/ruby/gems/2.0.0 directory.

```

Exited the `su` and tried to install it as root:

```plaintext
root@localhost:/var/discourse# ./launcher ssh app
WARNING: No memory limit support
WARNING: No swap limit support
lastlog_openseek: Couldn't stat /var/log/lastlog: No such file or directory
lastlog_openseek: Couldn't stat /var/log/lastlog: No such file or directory

Welcome to Discourse Docker

Use: rails, rake or discourse to execute commands in production

root@li895-63-app:~# gem install mysql2
Fetching: mysql2-0.3.18.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
        ERROR: Failed to build gem native extension.

    /usr/local/bin/ruby -r ./siteconf20150312-1794-3xmznr.rb extconf.rb
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... no
***extconf.rb failed***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=/usr/local/bin/ruby
        --with-mysql-dir
        --without-mysql-dir
        --with-mysql-include
        --without-mysql-include=${mysql-dir}/include
        --with-mysql-lib
        --without-mysql-lib=${mysql-dir}/
        --with-mysql-config
        --without-mysql-config
        --with-mysql-dir
        --without-mysql-dir
        --with-mysql-include
        --without-mysql-include=${mysql-dir}/include
        --with-mysql-lib
        --without-mysql-lib=${mysql-dir}/
        --with-mysqlclientlib
        --without-mysqlclientlib
        --with-mlib
        --without-mlib
        --with-mysqlclientlib
        --without-mysqlclientlib
        --with-zlib
        --without-zlib
        --with-mysqlclientlib
        --without-mysqlclientlib
        --with-socketlib
        --without-socketlib
        --with-mysqlclientlib
        --without-mysqlclientlib
        --with-nsllib
        --without-nsllib
        --with-mysqlclientlib
        --without-mysqlclientlib
        --with-mygcclib
        --without-mygcclib
        --with-mysqlclientlib
        --without-mysqlclientlib

extconf failed, exit code 1

Gem files will remain installed in /usr/local/lib/ruby/gems/2.0.0/gems/mysql2-0.3.18 for inspection.
Results logged to /usr/local/lib/ruby/gems/2.0.0/extensions/x86_64-linux/2.0.0-static/mysql2-0.3.18/gem_make.out
root@li895-63-app:~#

```

[Rails is known to be hard to install](http://askubuntu.com/questions/75916/why-is-it-so-difficult-to-setup-ruby-on-rails-on-ubuntu), and [Ruby is part of that problem](https://gorails.com/setup/ubuntu/14.04#comment-1902743216). This is makes the migration process quite painful and a traumatic experience for new users. How can we improve this? Are the some streamlined guidelines on importing data from other forums that I’ve missed?

**This doesn’t only apply to MyBB**. Running any migration script needs to get all these dependencies installed, and I’ve been running into errors after errors.

---

<div class="post-metadata">

### Author: ![elberet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elberet/32/122404_2.png) [@elberet](https://meta.discourse.org/u/elberet)
#### Post date: [March 12, 2015, 9:44am UTC](https://meta.discourse.org/t/migrating-from-mybb/25563/4 "2015-03-12T09:44:48Z")

</div>

> [@dandv](#):
>
> syntax error, unexpected ‘:’

No, if `bundle` wasn’t the right program, it wouldn’t have a known to look at the Gemfile; however, I’m guessing that there are several versions of Ruby installed on the machine and bundler was using an outdated Ruby. The shorthand hash assignment notation `symbol: "value"` (instead of `:symbol => "value"`) was introduced with Ruby 1.9.

> [@dandv](#):
>
> checking for pg\_config… no

The `pg` gem requires the native PostgreSQL client library and its C header files. On Ubuntu, `sudo apt-get install libpq-dev` should install these files.

> [@dandv](#):
>
> but couldn’t install the mysql2 gem

Either install the gem with `sudo` or install it in your user’s home directory with `gem install --user-install mysql2`. Newer versions of rubygems should actually do this automatically when run by a non-root user…

> [@dandv](#):
>
> checking for mysql\_query() in -lmysqlclient… no

This time around, you were running inside Discourse’s production container. The container hosts an Ubuntu userland separate from your host machine, so packages you installed on the host - e.g. the `mysql` client library - aren’t available inside. Running `apt-get install libmysqlclient-dev` in the container should fix this.

> [@dandv](#):
>
> and Ruby is part of that problem

I tend to disagree. The problem is that Ubuntu, even in the “server” flavour, is targeting ex-point&click users. Like many other binary distributions, compiling C code against libraries installed by the system package manager is impossible unless an additional `-dev` package is installed as well. Ruby, on the other hand, assumes that it runs on a full-featured POSIX platform where it is and always has been the custom to keep required C header files alongside installed library binaries.

> [@dandv](#):
>
> Running any migration script needs to get all these dependencies installed, and I’ve been running into errors after errors.

Yes, that I fully agree with, but I have no ideas for an easy solution. Perhaps an alternative docker image that includes mysql dependencies?

---

<div class="post-metadata">

### Author: ![dandv](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dandv/32/169779_2.png) [@dandv](https://meta.discourse.org/u/dandv)
#### Post date: [March 14, 2015, 2:02am UTC](https://meta.discourse.org/t/migrating-from-mybb/25563/5 "2015-03-14T02:02:37Z")

</div>

@elberet, thanks for your help so far. I went for the second option - connecting from the Discourse machine to the MySQL server of the running forum (set to maintenance mode) after enabling port 3306 in the firewall and setting `bind-address = 0.0.0.0` in `/etc/mysql/my.cnf` followed by a `sudo service mysql restart`. Here’s what I’ve done based on your advice:

```sh
cd /var/discourse
./launcher enter app
apt-get update
apt-get install libmysqlclient-dev mc -y
gem install mysql2 # mysql2-0.3.18 got installed
su - discourse
cd /var/www/discourse/script/import_scripts
bundle install
mcedit mybb.rb # make edits to the MySQL connection details
RAILS_ENV=production ruby mybb.rb # no idea what "bundle exec" does

```

To setup redirects from the old forum thread URLs to Discourse topics, see my other post:

[https://meta.discourse.org/t/redirecting-old-forum-urls-to-new-discourse-urls/20930/21?u=dandv](https://meta.discourse.org/t/redirecting-old-forum-urls-to-new-discourse-urls/20930/21)

---

<div class="post-metadata">

### Author: ![elberet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elberet/32/122404_2.png) [@elberet](https://meta.discourse.org/u/elberet)
#### Post date: [March 14, 2015, 10:48am UTC](https://meta.discourse.org/t/migrating-from-mybb/25563/6 "2015-03-14T10:48:56Z")

</div>

Try running `gem install mysql2` _after_ `su - discourse`.

---

<div class="post-metadata">

### Author: ![dandv](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dandv/32/169779_2.png) [@dandv](https://meta.discourse.org/u/dandv)
#### Post date: [March 15, 2015, 12:32am UTC](https://meta.discourse.org/t/migrating-from-mybb/25563/7 "2015-03-15T00:32:31Z")

</div>

That requires sudo, so I tried with --user-install, but got the same error in the end:

```plaintext
root@localhost:~# cd /var/discourse

root@localhost:/var/discourse# ./launcher enter app

WARNING: No memory limit support
WARNING: No swap limit support

root@li895-63-app:/# su - discourse

discourse@li895-63-app:~$ gem install mysql2
ERROR: While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /usr/local/lib/ruby/gems/2.0.0 directory.

discourse@li895-63-app:~$ gem install --user-install mysql2
WARNING: You don't have /home/discourse/.gem/ruby/2.0.0/bin in your PATH,
          gem executables will not run.
Building native extensions. This could take a while...
Successfully installed mysql2-0.3.18
1 gem installed

discourse@li895-63-app:~$ cd /var/www/discourse/script/import_scripts

discourse@li895-63-app:/var/www/discourse/script/import_scripts$ RAILS_ENV=production ruby mybb.rb
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.9/lib/active_support/dependencies.rb:247:in `require': cannot load such file -- mysql2 (LoadError)
        from /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.9/lib/active_support/dependencies.rb:247:in `block in require'
        from /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.9/lib/active_support/dependencies.rb:232:in `load_dependency'
        from /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.9/lib/active_support/dependencies.rb:247:in `require'
        from mybb.rb:3:in `<main>'
discourse@li895-63-app:/var/www/discourse/script/import_scripts$

```

---

<div class="post-metadata">

### Author: ![elberet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elberet/32/122404_2.png) [@elberet](https://meta.discourse.org/u/elberet)
#### Post date: [March 15, 2015, 1:00am UTC](https://meta.discourse.org/t/migrating-from-mybb/25563/8 "2015-03-15T01:00:33Z")

</div>

Ah, I see. I think `base.rb` changed recently and now loads the Rails environment immediately. This also loads `bundler` which overrides `require`, and since `mysql2` is not in Discourse’s bundle, it can’t be loaded.

Fixed here:  
[https://github.com/Elberet/discourse/commit/1cc7db23707a70889dd135c0cde32ff1850013e5](https://github.com/Elberet/discourse/commit/1cc7db23707a70889dd135c0cde32ff1850013e5)

Grab the update from my fork (or just edit it into your local copy of the script – it’s three lines…) or wait until it’s merged into the core repo. 🙂

CC @neil and @gerhard since the phpbb3 and, I’d assume, all other importers will likely have the same issue.

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [March 15, 2015, 1:15pm UTC](https://meta.discourse.org/t/migrating-from-mybb/25563/9 "2015-03-15T13:15:40Z")

</div>

I’m always adding `gem 'mysql2'` to the `Gemfile` which always seems to work, so I didn’t even notice that there is a problem.  
I guess I should read more about how Ruby handles its dependencies. Just to clarify, moving the `require 'mysql2'` to the top isn’t enough, is it? At least in my development environment I still get an error. So, how do I install the mysql gem without adding it to the `Gemfile` in order to make a simple `require 'mysql2'` work?

---

<div class="post-metadata">

### Author: ![elberet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elberet/32/122404_2.png) [@elberet](https://meta.discourse.org/u/elberet)
#### Post date: [March 15, 2015, 1:27pm UTC](https://meta.discourse.org/t/migrating-from-mybb/25563/10 "2015-03-15T13:27:12Z")

</div>

Adding it to the Gemfile is a dirty, dirty hack… most users will try to run the importer, get the error that `mysql2` can’t be loaded and will either give up and/or come to Meta for help.

Anyway, moving the `require` line to the top of the file _did_ actually work for me. The gem is installed in `~/.gem/ruby/2.2.0` and Ruby seems to have no problems picking it up from that directory even without any special environment variables or config files.

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [March 15, 2015, 1:42pm UTC](https://meta.discourse.org/t/migrating-from-mybb/25563/11 "2015-03-15T13:42:02Z")

</div>

> [@elberet](#):
>
> Anyway, moving the require line to the top of the file did actually work for me.

Ah, I see, it works when I run the script from the shell but not in my IDE. 😞  
Edit: Found the right checkbox. Now it works in my IDE too. No more editing the Gemfile. 😃

---

<div class="post-metadata">

### Author: ![Abdul\_Munim\_Zahid](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/abdul_munim_zahid/32/39786_2.png) [@Abdul\_Munim\_Zahid](https://meta.discourse.org/u/Abdul_Munim_Zahid)
#### Post date: [March 15, 2015, 9:55pm UTC](https://meta.discourse.org/t/migrating-from-mybb/25563/12 "2015-03-15T21:55:09Z")

</div>

Can you guide me a little bit on how to set up a local mysql server and populate it with data from my mybb database?

---

<div class="post-metadata">

### Author: ![cyborg](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cyborg/32/116226_2.png) [@cyborg](https://meta.discourse.org/u/cyborg)
#### Post date: [June 4, 2015, 2:47pm UTC](https://meta.discourse.org/t/migrating-from-mybb/25563/13 "2015-06-04T14:47:37Z")

</div>

I am getting at all times this:

```
    # sudo ruby vbulletin.rb 
/usr/local/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- mysql2 (LoadError)
	from /usr/local/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	from vbulletin.rb:1:in `<main>'

```

Do you have any advices? I am on 1.4 latest. I can’t run the import script @elberet

---

<div class="post-metadata">

### Author: ![Abdul\_Munim\_Zahid](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/abdul_munim_zahid/32/39786_2.png) [@Abdul\_Munim\_Zahid](https://meta.discourse.org/u/Abdul_Munim_Zahid)
#### Post date: [June 4, 2015, 5:16pm UTC](https://meta.discourse.org/t/migrating-from-mybb/25563/14 "2015-06-04T17:16:08Z")

</div>

Are you sure you have the mysql2 gem installed?

Try installing it in this directory as @elberet suggested:  
~/.gem/ruby/2.2.0

Worked for me back then!

---

<div class="post-metadata">

### Author: ![elberet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elberet/32/122404_2.png) [@elberet](https://meta.discourse.org/u/elberet)
#### Post date: [June 15, 2015, 9:09pm UTC](https://meta.discourse.org/t/migrating-from-mybb/25563/15 "2015-06-15T21:09:30Z")

</div>

You’re not supposed to run the migration script as `root`. If you really have to run it with admin privileges for some reason, make sure that any required gems are either installed globally or exist in root’s `~/.gem`.

---

<div class="post-metadata">

### Author: ![flameens](https://avatars.discourse-cdn.com/v4/letter/f/5f8ce5/32.png) [@flameens](https://meta.discourse.org/u/flameens)
#### Post date: [July 28, 2015, 4:35pm UTC](https://meta.discourse.org/t/migrating-from-mybb/25563/16 "2015-07-28T16:35:20Z")

</div>

I just used the script and the import went well, but didn’t migrate the user passwords. Is that by design, or am I missing something?

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [July 28, 2015, 5:02pm UTC](https://meta.discourse.org/t/migrating-from-mybb/25563/17 "2015-07-28T17:02:44Z")

</div>

Unless things have changed since when we migrated from vB, ~11 months ago, members needed to create a new password.

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [July 28, 2015, 6:02pm UTC](https://meta.discourse.org/t/migrating-from-mybb/25563/18 "2015-07-28T18:02:57Z")

</div>

Currently none of the importers can migrate passwords. @michaeld [talked about adding support](https://meta.discourse.org/t/more-generic-importer/28893/14) for the [discourse-migratepassword plugin](https://github.com/communiteq/discourse-migratepassword) to the base importer. Not sure if he’s still planning on doing it.

---

<div class="post-metadata">

### Author: ![SentinelX101](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sentinelx101/32/44700_2.png) [@SentinelX101](https://meta.discourse.org/u/SentinelX101)
#### Post date: [September 27, 2015, 12:38pm UTC](https://meta.discourse.org/t/migrating-from-mybb/25563/19 "2015-09-27T12:38:48Z")

</div>

I’m having trouble with an error once the mybb.rb script is running after following the solution that @dandv used.

```
loading existing groups...
loading existing users...
loading existing categories...
loading existing posts...
loading existing topics...

creating users
/var/www/discourse/script/import_scripts/mybb.rb:51:in `block in import_users': undefined local variable or method `users' for #<ImportScripts::MyBB:0x007f1cb24e0108> (NameError)
        from /var/www/discourse/script/import_scripts/base.rb:670:in `block in batches'
        from /var/www/discourse/script/import_scripts/base.rb:669:in `loop'
        from /var/www/discourse/script/import_scripts/base.rb:669:in `batches'
        from /var/www/discourse/script/import_scripts/mybb.rb:39:in `import_users'
        from /var/www/discourse/script/import_scripts/mybb.rb:24:in `execute'
        from /var/www/discourse/script/import_scripts/base.rb:45:in `perform'
        from /var/www/discourse/script/import_scripts/mybb.rb:189:in `<main>'

```

I have absolutely no idea what’s causing it, can anyone lend a hand?

**Edit: Fixed in recent commit. Thanks @techAPJ and @riking.**

[https://github.com/techAPJ/discourse/commit/38d8d46a4bfaee62ffb589a9d93991a0e31ae244](https://github.com/techAPJ/discourse/commit/38d8d46a4bfaee62ffb589a9d93991a0e31ae244)

---

<div class="post-metadata">

### Author: ![alexrcs](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alexrcs/32/63724_2.png) [@alexrcs](https://meta.discourse.org/u/alexrcs)
#### Post date: [July 21, 2016, 5:13pm UTC](https://meta.discourse.org/t/migrating-from-mybb/25563/20 "2016-07-21T17:13:43Z")

</div>

Hey guys, is there any chance you can add support for attachment migration to this script? This would be really helpful.

[Next page](https://meta.discourse.org/t/migrating-from-mybb/25563.md?page=2)
