This article is related to the article “How to get a full backup and database export of your marketplace”, which you can read here. It is also assumed that you already have the database export available. After reading this article, you should have a good overview on how to access the export file.

These instructions have written primarily for MacOS 10.14 (Mojave), but they should be compatible with most modern MacOS computers. If you have an older (5-10 or more years old) laptop with an older operating system, you might run into some compatibility issues. In this case, please contact help@sharetribe.com and we will do our best to help.

Introduction

After you have requested and received a database export file from us, the first thing you need to do is to unpack the compressed .zip file into a subfolder. MacOS comes with pre-installed software that can do this, you just need to double-click the zip file.

After you’ve uncompressed the file, you’ll recognize that the zip file contains the readme, the images folder which has all the images of your marketplace, and the <marketplacename>_export.sql file, which is the database file that has the rest of the content of your marketplace. This SQL file has, for example, all the information about your marketplace’s listings, user accounts, and more.

The .sql file is a so called database file, created in MySQL, which is an open-source relational database management system (you can read more here if you’re interested). You can open the .sql file in any normal text editor, but it can be difficult to interpret, especially if you have not worked with databases before. As such, even though it requires a bit of preparation, it’s usually a better idea to install proper database software and use that to open the file.

Instructions for MacOS

Contents

  1. Required software
  2. Installing the requirements
  3. Creating a blank database in MySQL
  4. Importing your own database file
  5. Browsing the database

1. Required software

  • MySQL Community Server 5.7
  • Sequel Pro database management application

2. Installing the requirements

MySQL Community Server 5.7:

  1. Go to https://dev.mysql.com/downloads/mysql/5.7.html#downloads
  2. Note: The link above takes you to the download page of MySQL 5.7. It is important that you download the MySQL version 5.7! The newest versions, from 8.0., are not compatible with this process.
  3. Select “5.7.26” as the version from the drop-down menu.
  4. Select “macOS” as the operating system from the drop-down menu.
  5. Select the file that has a description ending with “DMG Archive” (this may be called “macOS 10.14 (x86, 64-bit), DMG Archive”) and click on “Download”.
  6. Download and open the DMG file.
  7. Double-click on the PKG file inside the archive, and follow the installation instructions. Warning: do NOT dismiss the last dialogue box that shows you a password!
  8. When shown the automatically generated password for the “root” user at the end of the setup, be sure to write it down! It is required to access the database. When you have the password saved, you can finish the installer.
  9. Done! MySQL Community Server is now installed.

Sequel Pro database management application:

  1. Go to https://www.sequelpro.com/
  2. Click on the button labeled “DOWNLOAD” - this will get you the latest version.
  3. After the download has finished, locate and open the downloaded .dmg file; a new window should open when you do this.
  4. Copy (or drag+drop) the Sequel Pro app in your mac’s Applications folder.
  5. Done! Sequel Pro is now installed.

3. Creating a blank database in MySQL

In order to import/open the database file, you’ll need to first have an existing, blank database file, running on your own local database. The sql file is then imported on top of this blank file.

1. Open the System Preferences menu (more info here)

2. Select “MySQL” from the preferences menu

3. If the MySQL server status is “stopped”, click on “Start MySQL Server”

4. Open the terminal on your macbook (step-by-step guide here)

5. Enter this command, exactly as written:

/usr/local/mysql/bin/mysql -uroot -p 

6. Enter your root password which you got at the final step of the installation of the MySQL server. If you lost your root password, you need to reset it, which can be a bit tricky. You can read some instructions here, or search for “MySQL 5.7 reset root password” on Google.

7. When you are logged in and see the prompt that says “mysql>”, enter this command, but change ‘yourpassword’ to a secure password!:

ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘yourpassword’;  

You should see “Query OK, 0 rows affected (0,00 sec)”

NOTE: Changing the password from ‘yourpassword’ is important. Leaving any default weak password as your root password is a security risk.

NOTE: If you try copy-pasting the command, it may not function, since sometimes the terminal doesn’t understand copy-pasted quotation marks. If the command doesn’t work when copy-pasting, try writing it from scratch.

8. Enter this command, exactly as written:

create database marketplace; 

You should see “Query OK, 1 row affected (0,00 sec)”.


9. Enter this command, exactly as written:

use marketplace; 

You should see “Database changed”.

4. Importing your own database file

Locate your data export file, which ends in .sql. If you downloaded the archive to your “Downloads” folder, and unpacked it there, the path to the folder may be something like the following (replace the references to your username, marketplace name, and the number):

/Users/YOURUSERNAME/Downloads/YOURMARKETPLACE_1234567/ 

Note: There are two things you need to change here, to get the correct path. 

  1. You need to enter your own Mac username here, which you can find if you open a new terminal window and type “pwd”. You should see a line that says “/Users/YOURUSERNAME”, where the second part is your actual username.
  2. You need to change the folder name to whatever folder you unpacked the contents of the zip file in. Of course, if you unpacked it in a different folder, then you need to copy that folder structure instead of the template mentioned above.

Then, it's time to import the file.

Type the following command in the MySQL prompt. You need to change 2 things in the command below:

  1. Replace the word “PATH” with the full path you got from step above (the one where you replaced 'YOURUSERNAME'), and: 
  2. Replace “YOURMARKETPLACE” with your marketplace name. This is usually the original name of your marketplace, or the first part of the URL address of your trial marketplace, which was in the form of "https://YOURMARKETPLACE.sharetribe.com". If needed, you can check the exact file name of the .sql file from the folder where you uncompressed the backup in the first place.

Here's the command for the MySQL prompt (make sure you're in the prompt, and you replaced the 2 things mentioned above):

source /PATH/YOURMARKETPLACE_export.sql

You should see several rows worth of entries come up very quickly, saying things such as “Query OK, 0 rows affected (0.00 sec)”. This means everything worked well, and the database is now online and accessible with Sequel Pro or any other SQL client!

5. Browsing the database

  1. Open Sequel Pro
  2. Select QUICK CONNECT
  3. Add the Following information:
  4. Name: localhost
  5. Host: 127.0.0.1
  6. Username: root
  7. Password: The password that you changed in step 3.7
  8. Leave the other fields blank or with the default values
  9. Click the Connect button
  10. Once connected, go to the dropdown menu on the top left labelled “Choose Database” and from the menu select the option “marketplace”

That’s it! You can now browse through the Database. Bear in mind that some tables might be empty due to the nature of the Database dump. 

Did this answer your question?