Starting MindsDB with Extended Configuration
Start MindsDB locally with your custom configuration by providing a path to theconfig.json file that stores custom config parameters listed in this section.
Available Config Parameters
Below are all of the custom configuration parameters that should be set according to your requirements and saved into theconfig.json file.
permanent_storage
permanent_storage parameter defines where MindsDB stores copies of user files, such as uploaded files, models, and tab content. MindsDB checks the permanent_storage location to access the latest version of a file and updates it as needed.
The location specifies the storage type.
absent(default): Disables permanent storage and is recommended to use when MindsDB is running locally.local: Stores files in a local directory defined withconfig['paths']['storage'].s3: Stores files in an Amazon S3 bucket. This option requires thebucketparameter that specifies the name of the S3 bucket where files will be stored.
MINDSDB_STORAGE_DIR environment variable. MindsDB defaults to creating a mindsdb folder in the operating system user’s home directory.
paths
paths parameter allows users to redefine the file paths for various groups of MindsDB files. If only the root path is defined, all other folders will be created within that directory. If this parameter is absent, the value is determined by the MINDSDB_STORAGE_DIR environment variable.
The root parameter defines the base directory for storing all MindsDB files, including models, uploaded files, tab content, and the internal SQLite database (if running locally).
The content parameter specifies the directory where user-related files are stored, such as uploaded files, created models, and tab content. The internal SQLite database (if running locally) is stored in the root directory instead.
If the ['permanent_storage']['location'] is set to 'local', then the storage parameter is used to store copies of user files.
The static parameter is used to store files for the graphical user interface (GUI) when MindsDB is run locally.
The tmp parameter designates a directory for temporary files. Note that the operating system’s default temporary directory may also be used for some temporary files.
If the ['cache']['type'] is set to 'local', then the cache parameter defines the location for storing cached files for the most recent predictions. For example, if a model is queried with identical input, the result will be stored in the cache and returned directly on subsequent queries, instead of recalculating the prediction.
The locks parameter is used to store lock files to prevent race conditions when the content folder is shared among multiple applications. This directory helps ensure that file access is managed properly using fcntl locks. Note that this is not applicable for Windows OS.
auth
auth parameter controls the authentication settings for APIs in MindsDB.
If the http_auth_enabled parameter is set to true, then the username and password parameters are required. Otherwise these are optional.
In local instances of MindsDB, users can enable simple HTTP authentication based on bearer tokens, as follows:
-
Enable the authentication for the HTTP API by setting the
http_auth_enabledparameter totrueand providing values for theusernameandpasswordparameters. Alternatively, users can set the environment variables -MINDSDB_USERNAMEandMINDSDB_PASSWORD- to store these values.. - Bearer tokens are valid indefinitely.
gui
gui parameter controls the behavior of the MindsDB graphical user interface (GUI) updates.
The autoupdate parameter defines whether MindsDB automatically checks for and updates the GUI to the latest version when the application starts. If set to true, MindsDB will attempt to fetch the latest available version of the GUI. If set to False, MindsDB will not try to update the GUI on startup.
The open_on_start parameter defines whether MindsDB automatically opens the GUI on start. If set to true, MindsDB will open the GUI automatically. If set to False, MindsDB will not open the GUI on startup.
api
api parameter contains the configuration settings for running MindsDB APIs.
Currently, the supported APIs are:
http: Configures the HTTP API. It requires thehostandportparameters. Alternatively, configure HTTP authentication for your MindsDB instance by setting the environment variablesMINDSDB_USERNAMEandMINDSDB_PASSWORDbefore starting MindsDB, which is a recommended way for the production systems.mysql: Configures the MySQL API. It requires thehostandportparameters and additionally thedatabaseandsslparameters.
HTTP API
HTTP API
Connection parameters for the HTTP API include:
-
host: Specifies the IP address or hostname where the API should run. For example,"127.0.0.1"indicates the API will run locally. -
port: Defines the port number on which the API will listen for incoming requests. The default ports are47334for HTTP, and47335for MySQL. -
restart_on_failure: If it is set totrue(andmax_restart_countis not reached), the restart of MindsDB will be attempted after the MindsDB process was killed - with code 9 on Linux and MacOS, or for any reason on Windows. -
max_restart_count: This defines how many times the restart attempts can be made. Note that 0 stands for no limit. -
max_restart_interval_seconds: This defines the time limit during which there can be no more thanmax_restart_countrestart attempts. Note that 0 stands for no time limit, which means there would be a maximum ofmax_restart_countrestart attempts allowed.Here is a usage example of the restart features:Assume the following values:- max_restart_count = 2
- max_restart_interval_seconds = 30 seconds
- MindsDB fails at 1000s of its work - the restart attempt succeeds as there were no restarts in the past 30 seconds.
- MindsDB fails at 1010s of its work - the restart attempt succeeds as there was only 1 restart (at 1000s) in the past 30 seconds.
- MindsDB fails at 1020s of its work - the restart attempt fails as there were already max_restart_count=2 restarts (at 1000s and 1010s) in the past 30 seconds.
- MindsDB fails at 1031s of its work - the restart attempt succeeds as there was only 1 restart (at 1010s) in the past 30 seconds.
-
a2wsgiis an WSGI wrapper with the following parameters:workersdefines the number of requests that can be processed in parallel, andsend_queue_sizedefines the buffer size.
MySQL API
MySQL API
Connection parameters for the MySQL API include:
host: Specifies the IP address or hostname where the API should run. For example,"127.0.0.1"indicates the API will run locally.port: Defines the port number on which the API will listen for incoming requests. The default ports are47334for HTTP, and47335for MySQL.database: Specifies the name of the database that MindsDB uses. Users must connect to this database to interact with MindsDB through the respective API.ssl: Indicates whether SSL support is enabled for the MySQL API.restart_on_failure: If it is set totrue(andmax_restart_countis not reached), the restart of MindsDB will be attempted after the MindsDB process was killed - with code 9 on Linux and MacOS, or for any reason on Windows.max_restart_count: This defines how many times the restart attempts can be made. Note that 0 stands for no limit.max_restart_interval_seconds: This defines the time limit during which there can be no more thanmax_restart_countrestart attempts. Note that 0 stands for no time limit, which means there would be a maximum ofmax_restart_countrestart attempts allowed.
cache
cache parameter controls how MindsDB stores the results of recent predictions to avoid recalculating them if the same query is run again. Note that recent predictions are cached for ML models, like Lightwood, but not in the case of large language models (LLMs), like OpenAI.
The type parameter specifies the type of caching mechanism to use for storing prediction results.
none: Disables caching. No prediction results are stored.local(default): Stores prediction results in thecachefolder (as defined in thepathsconfiguration). This is useful for repeated queries where the result doesn’t change.redis: Stores prediction results in a Redis instance. This option requires theconnectionparameter, which specifies the Redis connection string.
connection parameter is required only if the type parameter is set to redis. It stores the Redis connection string.
logging
logging parameter defines the details of output logging, including the logging levels.
The handler parameter provides handlers used for logging into streams and files.
-
console: This parameter defines the setup for saving logs into a stream.- If the
enabledparameter is set totrue, then the logging output is saved into a stream. - Users can define the
formatterparameter that configures the format of the logs, where the available values includedefaultandjson. - Users can also define the logging level in the
levelparameter or in theMINDSDB_CONSOLE_LOG_LEVELenvironment variable - one ofDEBUG,INFO,WARNING,ERROR,CRITICAL.
- If the
-
file: This parameter defines the setup for saving logs into a file.- If the
enabledparameter is set totrue, then the logging output is saved into a file. - Users can define the logging level in the
levelparameter or in theMINDSDB_FILE_LOG_LEVELenvironment variable - one ofDEBUG,INFO,WARNING,ERROR,CRITICAL. - Additionally, the
filenameparameter stores the name of the file that contains logs. - And the
maxBytesandbackupCountparameters determine the rollover process of the file - that is, if the file reached the size ofmaxBytes, then the file is closed and a new file is opened, where the number of files is defined by thebackupCountparameter.
- If the
ml_task_queue
ml_task_queue parameter manages the queueing system for machine learning tasks in MindsDB. ML tasks include operations such as creating, training, predicting, fine-tuning, and retraining models. These tasks can be resource-intensive, and running multiple ML tasks simultaneously may lead to Out of Memory (OOM) errors or performance degradation. To address this, MindsDB uses a task queue to control task execution and optimize resource utilization.
The type parameter defines the type of task queue to use.
local: Tasks are processed immediately as they appear, without a queue. This is suitable for environments where resource constraints are not a concern.redis: Tasks are added to a Redis-based queue, and consumer process (which is run with--ml_task_consumer) ensures that tasks are executed only when sufficient resources are available.- Using a Redis queue requires additional configuration such as the
host,port,db,username, andpasswordparameters. - To use the Redis queue, start MindsDB with the following command to initiate a queue consumer process:
python3 -m mindsdb --ml_task_queue_consumer. This process will monitor the queue and fetch tasks for execution only when sufficient resources are available.
- Using a Redis queue requires additional configuration such as the
url_file_upload
url_file_upload parameter restricts file uploads to trusted sources by specifying a list of allowed domains. This ensures that users can only upload files from the defined sources, such as S3 or Google Drive.
The enabled flag turns this feature on (true) or off (false).
The allowed_origins parameter lists allowed domains. If left empty, then any domain is allowed.
The disallowed_origins parameter lists domains that are not allowed. If left empty, then there are no restricted domains.
web_crawling_allowed_sites
web_crawling_allowed_sites parameter restricts web crawling operations to a specified list of allowed IPs or web addresses. This ensures that the application only accesses pre-approved and safe URLs ("web_crawling_allowed_sites": ["https://example.com", "https://api.mysite.com"]).
If left empty ([]), the application allows access to all URLs by default (marked with a wildcard in the open-source version).
default_llm
default_llm parameter specifies the default LLM that will be used with the LLM() function, the TO_MARKDOWN() function, and as a default model for agents.
default_embedding_model
default_embedding_model parameter specifies the default embedding model used with knowledge bases. Learn more about the parameters following the documentation of the embedding_model of knowledge bases.
default_reranking_model
default_reranking_model parameter specifies the default reranking model used with knowledge bases. Learn more about the parameters following the documentation of the reranking_model of knowledge bases.
data_catalog
Example
First, create aconfig.json file.
config.json file.
Modifying Config Values
Users can modify config values by directly editing theconfig.json file they created.