Skip to main content

Overview

Building VillageSQL from source gives you the latest features and allows you to customize the build for your specific environment.

Prerequisites

Before you begin, ensure you have the following installed:
  • Git - For cloning the repository
  • CMake 3.16 or higher - Build system generator
  • C++ Compiler - GCC 8+, Clang 8+, or MSVC 2019+
  • Build tools - make, ninja, or equivalent
  • Development libraries - OpenSSL, ncurses, pkg-config, bison, and other MySQL dependencies

Install Dependencies

Ubuntu/Debian:
macOS (using Homebrew): First, install Homebrew if you haven’t already:
Then install dependencies:

Step 1: Clone the Repository

Clone the VillageSQL Server repository from GitHub. Clone into your home directory so the CMake steps below work without modification:
The repository is several GB due to the MySQL codebase.

Step 2: Configure with CMake

Create a build directory outside the repository and configure the project: Linux:
macOS:
Linux users: Use $HOME for absolute paths. macOS users: Use ~ (tilde). Replace the repository path with your actual clone location if different.

CMake Options Explained

  • <path-to-repo> - Path to the cloned VillageSQL repository (use $HOME on Linux, ~ on macOS)
  • -DWITH_DEBUG=1 - Enables debug symbols (recommended for development)
  • -DCMAKE_INSTALL_PREFIX=~/mysql - Sets installation directory
  • -DWITH_SSL=system - Uses system OpenSSL library (required on macOS)

Additional CMake Options

Production build without debug symbols: Linux:
macOS:
With custom compilation comment: Linux:
macOS:
Developer mode with stricter warnings: Linux:
macOS:
If you need to reconfigure, clear the CMake cache first (run from within the build directory):

Step 3: Compile the Code

Build VillageSQL using make with parallel compilation. From within the build directory: Build only the server (recommended for development):
Build everything:
Adjust the parallelism (-j10) based on your CPU cores. Subtract 2-4 from your total core count to keep your system responsive. For example, on a 12-core machine, use -j10.
When complete, verify the server binary was built: Linux:
macOS:

Step 4: Initialize the Database

Before starting the server for the first time, initialize the data directory: Linux: Production (with generated password - recommended):
Development (no password - optional):
Running as root (Docker or sudo): If running as root (e.g., in Docker), MySQL requires the --user=root flag:
macOS: Production (with generated password - recommended):
Development (no password - optional):
Use --initialize (with password) for production-like setups. Use --initialize-insecure (no password) only for local development and testing. When using --initialize, a temporary password will be generated and printed to the console: A temporary password is generated for root@localhost: <password>
Verify initialization succeeded by checking that the system databases were created: Linux:
macOS:

Step 5: Start the Server

Start the VillageSQL server: Linux:
Running as root (Docker or sudo):
macOS:
The --gdb flag installs a SIGINT handler so Ctrl-C stops the server cleanly — useful when running interactively from a terminal. To run in the background, add --daemonize to the mysqld command.

Step 6: Connect with MySQL Client

Open a new terminal and connect to the server using the MySQL client: Linux: If using —initialize-insecure (no password):
If using —initialize (with generated password):
macOS: If using —initialize-insecure (no password):
If using —initialize (with generated password):
You should see the MySQL prompt:

Verify Installation

Check that you’re running VillageSQL:
Development builds include the git commit hash in the version string:

Step 7: Set Up Users and Database

Change Root Password

If you used --initialize, change the temporary password:

Create a Development User

For daily development, create a non-root user:
Exit and reconnect as your new user: Linux:
macOS:

Create a Database

Connect to a specific database: mysql -u developer -p -D my_database
For GDB debugging, running tests, and contributing to the server codebase, see the Server Development Guide.

Troubleshooting

Build Fails with Missing Dependencies

Install the required development packages for your platform. Check the error message for specific missing libraries.

Server Won’t Start

  • Verify the data directory was initialized: ls ~/mysql-data/data/
  • Check if another MySQL/VillageSQL instance is using port 3306
  • Review error logs in ~/mysql-data/data/*.err

Extension Installation Fails

  • Ensure the extension library (.so or .dll) exists in the build output
  • Check that VillageSQL has the necessary permissions to load extensions
  • Verify the extension name and .veb filename are correct

Next Steps

Using Extensions

Learn how to install, update, and manage VillageSQL extensions.

Creating Extensions

Build your own custom extensions for VillageSQL.

Getting Started

Quick start guide for VillageSQL.