Default MariaDB database and user
Zerops creates a default database and a default user automatically when a new MariaDB service is created.Database
The default database name is identical to the service hostname. The default encoding is set toutf8mb4.
DB user
Default user name is identical to the service hostname. Default user password is generated randomly. You will find the password in Zerops GUI or you can use the environment variable.Zerops creates a second DB user:
zps for maintenance reasons with full privileges. Do not delete, change the password or remove privileges from this user, it will disrupt Zerops ability to maintain the database cluster.Copy access details from Zerops GUI
You will find the MariaDB access details under the Access details button in the project dashboard page. The same information is available in the service detail page in the left menu under the Peek access details button.MariaDB access parameters
| Parameter | Description |
|---|---|
| Hostname | The service hostname specified when the MariaDB service was created. |
| Port | 3306 This port is fixed for all MariaDB services and cannot be customized. |
| User | Zerops creates a database user automatically when the service is created. The user name is always identical to the service hostname. |
| Password | Zerops sets a random password when the service is created. |
| Connection string | The connection string for MariaDB service is:mysql://${user}:${password}@{hostname}:3306 |
Connect to MariaDB from runtime services of the same project
Projects in Zerops represent a group of one or more services. Services can be of different types (runtime services, databases, message brokers, object storage, etc.). All services of the same project share a dedicated private network. To connect to a service within the same project, just use the service hostname and its internal port.Direct Connection Example
To connect to MariaDBdatabase1 service, set:
Use MariaDB environment variables
Zerops creates default environment variables for each MariaDB service to help you with connection from runtime services in the same project. To avoid the need to copy database access parameters manually, use environment variables in your runtime service.Prefix the environment variable key
All services of the same project can reference environment variables from other services. To use an environment variable from one service in another service in the same project, you must prefix the environment variable key with the service hostname and underscore.Example
To access theconnectionString env variable of the mariadb1 service, use mariadb1_connectionString as the env variable key.
To access the password env variable of the mariadb2 service, use mariadb2_password as the env variable key.
MariaDB environment variables
List of service environment variables is available in Zerops GUI. Go to a MariaDB service detail and choose Environment variables in the left menu. Zerops creates following environment variables when the MariaDB service is created:| Variable | Description |
|---|---|
| hostname | The service hostname specified when the MariaDB service was created. |
| port | 3306 This port is fixed for all MariaDB services and cannot be customized. |
| projectId | ID of the project. Generated by Zerops. |
| serviceId | ID of the MariaDB service. Generated by Zerops. |
| connectionString | The connection string for MariaDB service is:mysql://${user}:${password}@{hostname}:3306Connection string contains references to user and password variables. Each time the user or password variable is updated, the connectionString variable is automatically updated as well. |
| user | Zerops creates a database user automatically when the service is created. The user name is always identical to the service hostname. |
| password | Zerops sets a random password when the service is created. |
Connection Examples
Connect to MariaDB in Zerops remotely
Connect via Zerops VPN
You can securely connect to MariaDB from your local workspace via Zerops VPN. Zerops VPN client is included into zCLI, the Zerops command-line tool.Install & setup zCLI
Install and configure zCLI if you haven’t already.
Start the Zerops VPN
Start the VPN connection to your project.
Get connection details
Copy the access details manually from Zerops GUI.
Environment variables are not available when connected through VPN.
Connect with your tool
Use your preferred database management tool or command-line client to connect.
Stop the VPN when finished
Stop the Zerops VPN when you’re done.
Using mysql CLI
If you use the mysql command-line client to manage your MariaDB on your local workspace, you can connect it securely to MariaDB via Zerops VPN. Once the VPN session is established, you have the secured connection to the project’s private network in Zerops. You can access all project services locally by using their hostname. Usemysql command to connect to MariaDB in Zerops:
Connect to MariaDB from another Zerops project
All services of the same project share a dedicated private network. You can use the service hostname to connect from one service to another within the same project. Different Zerops projects have no special connection. They can communicate with each other only via the internet. If you need to connect to a MariaDB service in a Zerops project from a runtime service in another project, you need to use the Zerops VPN.Next Steps
Manage MariaDB
Learn how to manage users and databases