For others wishing to import a mybb MySQL database, here’s what worked for me, from start to finish. My mybb was hosted on a server with cpanel.
I used a live fresh-install of Discourse on DigitalOcean. It is advised elsewhere to import into a local developer Discourse and then backup that Discourse and restore into the live one. However that is rather involved if you’re not a regular Github and Vagrant user (see this and this). So if the live Discourse is new, why not import right into it. If everything breaks, I can start over and have Discourse back up in 30 mins.
Start by performing a new Discourse backup through admin pages, and download it.
Then you need to allow remote MySQL connections from the new (Discourse) server.
I used cpanel where my mybb forum is hosted, and clicked on “Remote MySQL” and entered the Discourse server IP there.
Then collect the mybb database connection details. In cpanel you can see these under “MySQL databases”. Note the database name, the user, and look up in your records the password for that user (you did make a record of that, right?!) For the IP of the server where your mybb forum resides, you may be able to just do a DNS lookup on the domain name. But my hosting provider advised using a different IP for the server where the shared hosting resides. (Both may work, I am not sure.) If your table prefix is not “mybb_”, you’ll need to edit that too (you can check in phpMyAdmin from cpanel).
Now, ssh to your Discourse install. I did this as root, with PuTTY.
cd /var/discourse/ ./launcher enter app apt-get update apt-get install libmysqlclient-dev nano gem install mysql2 su - discourse cd /var/www/discourse/script/import_scripts bundle install
…and edit the connection details (MYBB_DB, host, username, password). I also needed to comment out the two lines beginning
next if, and reduce the BATCH_SIZE to 50 (see above in this topic for more info).
To save the file in nano, ctrlO. To exit nano, ctrlX.
Now go back to your mybb admin page and put the board into offline mode, in the Configuration tab.
Now back in your ssh window to your Discourse install,
RAILS_ENV=production ruby mybb.rb
At this point, for me, the script executed successfully. Check your Discourse install - is everything there? (Don’t be fooled by the Dashboard stats, they may not update for a while)
In the online Discourse admin UI, perform another backup, and download it. There now may be some manual cleanup of posts required (links, attachments etc).
Once the import is complete,
exit out of the discourse login
exit out of the Rails app
If you now
./launcher rebuild app
the libmysqlclient-dev, nano, and mysql2 gem installations should be removed, as well as your edits to mybb.rb.
Thanks to @elberet, @dandv and @gerhard for their posts on this task