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 Database parameter, which is used to import the MariaDB database folder from a UCloud workspace. 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:
2021-06-02 11:24:36+02:00 [Note] [Entrypoint]: GENERATED ROOT PASSWORD: <root_temporary_password> ⋮ 2021-06-02 11:24:54 0 [Warning] You need to use --log-bin to make --expire-logs-days or --binlog-expire-logs-seconds work. 2021-06-02 11:24:54 0 [Note] Server socket created on IP: '0.0.0.0'. 2021-06-02 11:24:54 0 [Note] Server socket created on IP: '::'. 2021-06-02 11:24:54 0 [Warning] 'proxies_priv' entry '@% root@j-4fe7e2b4-bf8a-4684-b6e4-3ea061b8f83f-job-0' ignored in --skip-name-resolve mode. 2021-06-02 11:24:54 0 [Note] mysqld: ready for connections. Version: '10.6.1-MariaDB-1:10.6.1+maria~focal' socket: '/run/mysqld/mysqld.sock' port: 3306 mariadb.org binary distribution 2021-06-02 11:24:54 0 [Note] InnoDB: Buffer pool(s) load completed at 210602 11:24:54
<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:
$ mysql -u root -p
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';
Query OK, 0 rows affected (0.20 sec)
This password will be used to access the database next time the server is deployed.
A custom root password can also be assigned before submitting the job using the parameter Password or 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;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> FLUSH PRIVILEGES;
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.
On the one hand, if the client application runs within another interactive app available on UCloud (see, e.g., OmniDB), 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.
On the other hand, if 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.
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 parameter Configuration. 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 MySQL console, use the commands:
MariaDB [(none)]> SELECT @@GLOBAL.innodb_data_file_path;
| @@GLOBAL.innodb_data_file_path |
| ibdata1:12M:autoextend |
1 row in set (0.00 sec)
MariaDB [(none)]> SHOW VARIABLES;
For more information about option files, check the official documentation here.