In this tutorial, we will learn how to migrate MyBB forum to platform using the official MyBB Importer script.
What can be migrated
- Root category => root category
- Child category => sub category
- Root Forum => sub category
- child forum => sub category
- Threads & replies => topics & posts
- privilege status
- joining status
Our plan is very simple:
- Setup the local DEV environment.
- Exporting the production database.
- Importing the production database to Discourse.
- Running MyBB importer script.
Let’s get started
Setup The Local DEV Environment
First of all, you need to follow one of these guides to install Discourse platform itself. Consult this guide if you have any problems.
Install MySQL database server;
$ brew install email@example.com $ echo 'export PATH="/firstname.lastname@example.org/bin:$PATH"' >> ~/.bash_profile $ source ~/.bash_profile
Check the service status:
$ brew services list
You should see something like this:
Otherwise, run the following and try again:
$ brew services start email@example.com
$ sudo apt update $ sudo apt install mysql-server -y
After finishing installing MySQL, check its status:
$ systemctl status mysql.service
If it’s not running, run the following:
$ sudo systemctl start mysql
For Windows, you can follow the official installation guide
We will call this environment: Discourse server.
Exporting The Production Database
Export/Backup the production database (from MyBB production server) by running:
$ mysqldump -u USER_NAME -p DATABASE_NAME > mybb_dump.sql
- Copy this database dump to the Discourse server.
You can use
rsyncto copy the database.
Importing The Production Database to Discourse
On Discourse server, Create a database:
$ mysql -u root
If your DB user has a password, you should use:
mysql -u root -pthen type your password.
mysql> CREATE DATABASE mybb;
Make sure that the database has been created successfully by running:
mysql> SHOW DATABASES;
You should see something like:
+--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | mybb | | sys | +--------------------+
mybb DB is empty by now. Our next step is to import the production database into it.
$ mysql -u root mybb < mybb_dump.sql
Later, we will need the table prefix. So, While we are here, let’s get it.
$ mysql -u root mysql> USE mybb; mysql> SHOW TABLES;
You will see something like this:
+--------------------------+ | Tables_in_mybb | +--------------------------+ | mybb_adminlog | | mybb_adminoptions | | mybb_adminsessions | | mybb_adminviews | | mybb_announcements | | mybb_attachments | | mybb_attachtypes | | ...The rest of tables....| +--------------------------+
Our table prefix is
mybb_ as the output shows.
Running MyBB Importer Script
- Let’s first install the importer dependencies. From Discourse server:
$ cd ~/discourse $ echo "gem 'mysql2', require: false" >> Gemfile $ bundle install
Next, you should configure the script to run properly. Copy and paste the following into your shell (change the values if necessary):
export DB_HOST="localhost" export DB_NAME="mybb" export DB_PW="" export DB_USER="root" export TABLE_PREFIX="mybb_"
You have other option to configure the script. Open
script/import_scripts/mybb.rb in any editor of your choice and change the values inside the double quotation to fits your needs:
DB_HOST ||= ENV['DB_HOST'] || "localhost" DB_NAME ||= ENV['DB_NAME'] || "mybb" DB_PW ||= ENV['DB_PW'] || "" DB_USER ||= ENV['DB_USER'] || "root" TABLE_PREFIX ||= ENV['TABLE_PREFIX'] || "mybb_"
Run the importer with a clean Discourse instance:
$ bundle exec rails db:drop $ bundle exec rails db:create $ bundle exec rails db:migrate $ bundle exec ruby script/import_scripts/mybb.rb
The importer will connect to MySQL server and migrates your MyBB database to Discourse database.
After the importer finish, start Discourse instance by running:
$ bundle exec rails server
Next, start Sidekiq (background jobs processor) to process the migrated data:
$ bundle exec sidekiq
You can monitor sidekiq progress at
Setup your Discourse production server by following this tutorial.
Perform a backup for Discourse platform (local Discourse Server) and upload it to your Discourse production server by following this tutorial.
If you have any questions about the process I am happy to help.