MariaDB Server¶
MariaDB is a community-developed fork of the MySQL relational database management system.
For more information, check the official documentation here.
Create a New Server¶
The app requires to set the MARIADB_DATA parameter, which is used to import the MariaDB database folder from a UCloud project.
If the folder is empty, a new database will be initialized. In this case, after the initialization procedure is completed, the following lines will be displayed in the output logs:
Tip
2025-08-22 15:21:18+02:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:12.0.2+maria~ubu2404 started.
2025-08-22 15:21:18+02:00 [Note] [Entrypoint]: Initializing database files
2025-08-22 15:21:35+02:00 [Note] [Entrypoint]: Database files initialized
2025-08-22 15:21:35+02:00 [Note] [Entrypoint]: Starting temporary server
2025-08-22 15:21:35+02:00 [Note] [Entrypoint]: Waiting for server startup
⋮
2025-08-22 15:21:46+02:00 [Note] [Entrypoint]: GENERATED ROOT PASSWORD: <root_temporary_password>
2025-08-22 15:21:46+02:00 [Note] [Entrypoint]: Securing system users (equivalent to running mysql_secure_installation)
⋮
2025-08-22 15:21:49 0 [Note] Server socket created on IP: '0.0.0.0', port: '3306'.
2025-08-22 15:21:49 0 [Note] Server socket created on IP: '::', port: '3306'.
2025-08-22 15:21:49 0 [Note] mariadbd: Event Scheduler: Loaded 0 events
2025-08-22 15:21:49 0 [Note] mariadbd: ready for connections.
where <root_temporary_password>
is a random alphanumeric string which must be used to log in to the database for the first time. In order to change the password, the user should open the app terminal interface and access the database with the command:
$ mariadb -u root -p
Tip
Enter password:
The login administrator password <root_temporary_password>
must be copied from the output logs, as in the example above, and pasted in the terminal. Once inside the MariaDB console, a new password should be created with the command:
MariaDB [(none)]> ALTER USER 'root'@'localhost' IDENTIFIED BY 'AdminPassword';
Tip
Query OK, 0 rows affected (0.20 sec)
This password will be used to access the database next time the server is deployed.
Note
A custom root password can also be assigned before submitting the job using the parameter MARIADB_ROOT_PASSWORD or MARIADB_ROOT_PASSWORD_FILE. In this case it is not necessary to reset the password after the first log in.
Connect to the Server¶
As discussed above, the user can access the MariaDB console directly from the app terminal interface. However, it is also possible to connect to the server using an external client application. In this case, one has to grant remote access to the database user, e.g., using the following commands from the MariaDB console:
MariaDB [(none)]> GRANT ALL ON *.* to 'root'@'%' IDENTIFIED BY 'AdminPassword' WITH GRANT OPTION;
Tip
Query OK, 0 rows affected (0.00 sec)
and
MariaDB [(none)]> FLUSH PRIVILEGES;
Tip
Query OK, 0 rows affected (0.36 sec)
In this example the database user coincides with the server administrator. Connections from any external host are allowed. In order to restrict access to the server from only one specific host, it is necessary to replace the %
in the command above with the corresponding host IP address.
If the client application runs within another interactive app available on UCloud, one can connect directly to the MariaDB server, as outlined here. In this case the server hostname is configured as an external parameter via the option Connect to other jobs.
If, however, the MariaDB client is a third-party application, which is not deployed on UCloud, it is necessary to assign a static IP address to the server, using the corresponding option Public IP.
Note
By default remote access to the MariaDB server is established over the TCP port 3306
. The same port should be open on the network firewall of the public IP address.
Use Option Files¶
A customized server configuration can be specified using the MARIADB_CONFIG_FILE optional parameter. An example is shown below:
[client-server]
port=3306
socket = /run/mysqld/mysqld.sock
[mysqld]
port=3306
socket = /run/mysqld/mysqld.sock
key_buffer_size=16M
max_allowed_packet=128M
bind-address=0.0.0.0
To check the global configuration variables from the MariaDB console, use the commands:
MariaDB [(none)]> SELECT @@GLOBAL.innodb_data_file_path;
Tip
+--------------------------------+
| @@GLOBAL.innodb_data_file_path |
+--------------------------------+
| ibdata1:12M:autoextend |
+--------------------------------+
1 row in set (0.00 sec)
and
MariaDB [(none)]> SHOW VARIABLES;
For more information about option files, check the official documentation here.
Contents