# Installation in Minutes MemberJunction is an open-source platform designed to help organizations efficiently manage data, build applications, and leverage AI for better insights. This installation guide will walk you through the complete setup process, from initial requirements to final configuration. ## Prerequisites * [ ] SQL Server Database created – Supports SQL Server 2022 and above. Can be Azure SQL Server or regular SQL Server. Note: Azure SQL is currently recommended to avoid additional steps required to establish trust between a regular SQL connection and the server certificate. * [ ] On the computer you are installing MemberJunction: * [ ] NodeJS 20+ * [ ] Local working directory. Create a directory on your computer that will be used for MemberJunction work. We highly recommend that this repository is a clone of a remote git repository in your favorite git tool such as GitHub, Bitbucket, etc. > πŸ“˜ The process of installation attempts to run CodeGen to generate local code for your database. If you are starting with an empty database then this won’t result in new Entities or other artifacts being created in the metadata or code being generated. If you follow the above process and then separately get your data into the database, you can manually run CodeGen again at any time. ## Steps ### 1. [Download MemberJunction](https://memberjunction.readme.io/docs/downloads) * Select the version you want to download from [this page](https://memberjunction.readme.io/docs/downloads) * Download and unzip the file on your local computer into the working directory noted above in Prerequisites, where you want to work on MemberJunction ### 2. SQL Server Setup * Make sure you have your SQL Server and Database setup and ready to go * That database can have existing tables in it, just make sure there is no existing schema named β€œ\_\_mj” as MemberJunction installs its tables, by default, into a schema called β€œ\_\_mj”. If you do have a schema named β€œ\_\_mj”, you will need to modify the table installation script and set configuration variables differently in the CodeGen and MJAPI projects to make MemberJunction work off a different schema. * **Create the following Database Logins within the master database of the SQL server.** Connect to the **master** database and create the required SQL Server logins: ```sql USE master; GO -- Create the CodeGen login (used for schema management and code generation) CREATE LOGIN [MJ_CodeGen] WITH PASSWORD = 'YourStrongPassword1!'; -- Create the Connect login (used for application data access) CREATE LOGIN [MJ_Connect] WITH PASSWORD = 'YourStrongPassword2!'; ``` > **Important**: Replace the passwords with strong, unique passwords. These credentials will be used in your configuration files. * **Create Database Users and Assign Permissions.** Now switch to your **target MemberJunction database** (not the master database) and create the corresponding users: ```sql USE [YourMemberJunctionDB]; GO -- Create database users for the logins CREATE USER [MJ_CodeGen] FOR LOGIN [MJ_CodeGen]; CREATE USER [MJ_Connect] FOR LOGIN [MJ_Connect]; -- Assign permissions EXEC sp_addrolemember 'db_owner', 'MJ_CodeGen'; EXEC sp_addrolemember 'db_datareader', 'MJ_Connect'; EXEC sp_addrolemember 'db_datawriter', 'MJ_Connect'; ``` > **Note**: The `MJ_CodeGen` user needs `db_owner` permissions to create and modify database schema during installation and updates. The `MJ_Connect` user only needs read/write permissions for normal application operations. ### 3. Initialize database * A configuration file called `mj.config.js` must be present to run migrations. The distribution package includes this configuration file which may be edited to configure how the various MemberJunction components behave. The default configuration reads some values from environment variables which can be provided as a `.env` file (note that we recommend not including `.env` files in your Git repository) ```shell yaml # Your database name dbDatabase: MJ_DATABASE # The server on which your database resides dbHost: localhost # A login for that database server with admin authorization codeGenLogin: privileged_login # The password for the privileged login codeGenPassword: 'VeryStr0ngP@ssw0rd' # Y for local connections using a self-signed certificate dbTrustServerCertificate: Y # Your database name DB_DATABASE=MJ_DATABASE # The server on which your database resides DB_HOST=localhost # A login for that database server with admin authorization CODEGEN_DB_USERNAME=privileged_login # The password for the privileged login CODEGEN_DB_PASSWORD='VeryStr0ngP@ssw0rd' # Y for local connections using a self-signed certificate DB_TRUST_SERVER_CERTIFICATE=Y # A login for that database server with basic authorization DB_USERNAME=api_login # The password for the basic login DB_PASSWORD='VeryStr0ngP@ssw0rd' # The password for the basic login # Details for Microsoft Entra (MSLA) authentication TENANT_ID=d7d0c6b8-77fe-4710-be21-c5cd8ddb52ce WEB_CLIENT_ID=f58fbea0-c82d-4efb-911c-ee240614cd17 # Alternatively, using Auth0 authentication AUTH0_DOMAIN=dev-9ydqm0sWvrRk8csZ.us.auth0.com AUTH0_CLIENT_ID=mSEjf2qX9KGMwHcVuEzwaCIwqHFcruS2 AUTH0_CLIENT_SECRET=BHb1KOO_mUdaa-bOsezfc0Xl1_skJUvpVJn-nj8rsncw4bC2qX9OhTJskJUvpVJn # Allow Graphql introspection queries for development and testing ENABLE_INTROSPECTION=true ``` * Install the MJ CLI tool globally to manage your installation * ```shell npm install --global @memberjunction/cli ``` * Verify its version, if desired * ```shell mj version ``` * Finally, run the migration command to initialize the database. By default the migration tool will run migrations from the `./migrations` directory locally, but it can also run any v2.0.0+ migrations directly from Github * ```shell mj migrate -t main ``` * The migration tool will setup a new MJ database, or update any existing v2.0+ database, but **will not** migrate any pre-2.0 database. It is recommended to reinstall MJ for v2.0 whenever possible as each installation's migration path may be unique. > πŸ“˜ Run MJAPI before you run MJExplorer, the local API server is needed for MJExplorer (and any other API client) to run. ### 4. Run the MemberJunction Installer script * Run the MemberJunction Installer script with the following command in a terminal window from the root of where you unzipped the download file: * ```shell mj install ``` * The installer script will ask you a series of questions. Instead of answering these questions in the console, you can opt to fill in the **install.config.json** file that will be part of the zip file. If you intend to run the MJ Installer more than once you can save this install.config.json file and reuse it, **saving a lot of time** compared to manually answering the questions in the installer script each time. > πŸ“˜ MJExplorer is a useful application to test on your installation of MemberJunction. Even if you don’t plan to use MJ Explorer for your environment, running it successfully and by browsing some of your data helps you validate that your installation proceeded correctly. ### 5. At this point, you can run MemberJunction API and Explorer to test your install: * From the MJAPI directory, run the project either in a debugger environment like VSCode, or just run it with a node command line * In a new console window, from the MJExplorer directory, after MJAPI is up and running, run MJExplorer. Either run it in debug mode in VSCode, or run ng serve from the command line in the directory. > πŸ‘ After you complete the above steps you should have a functioning installation of MemberJunction on your local computer.