Author: Pawe Gowacki
One of the biggest new RAD Studio 10.2 Tokyo database features is support for MariaDB open-source relational database.
MariaDB is one of the most popular open-source SQL databases. It is a fork from MySQL database, after it has been acquired by Oracle, the original creators of MySQL, started to work on MariaDB, which is highly compatible, some say 95%, with MySQL. Consequently you will not find a new “MariaDB” node in RAD Studio “Data Explorer”, but existing FireDAC MySQL driver has been reworked and extended to support MariaDB down to 5.5 version.
The latest stable MariaDB version is 10.1.22 and it is available on multiple platforms. Here I’m going to walk you through the steps of installing MariaDB and connecting to it using FireDAC. I have RAD Studio 10.2 Tokyo Architect installed on my Window 10 virtual machine. Download the 32-bit Windows MariaDB installer from MariaDB downloads and run it. Accept the license and keep default settings in the “Custom Setup” installer screen.
On the “Default instance properties” screen you will have to enter and re-enter password for “root” user. On the following screen keep the default values for service name (“MySQL”), TCP port (“3306”) and buffer pool size. Note that these values are the same as in the standard MySQL installation. Click “Next” and on last screen click on “Install” button. In few moments MariaDB should be installed on your system.
The next step is to add the directory where MariaDB vendor library is located to the path, so the FireDAC driver could find it. The name of the library is “libmysql.dll” and it is located in the default installation in the “C:\Program Files (x86)\MariaDB 10.1\lib” folder. In Windows 10 “Search” type “path” and select “Edit the System Environment Variables” and in the dialog add MariaDB lib path to global Windows path.
Start RAD Studio, Delphi or C++Builder and click on the “Data Explorer” tab under the “Project Manager” window and expand “MySQL Server” node under FireDAC data sources and add “MariaDB_Test” new node. “Test” is an empty database that is installed with default MariaDB installation, so we will create a FireDAC connection to this database.
Right-click on the new node in the Data Explorer and select “Modify” from the context menu. Now enter as database “test”, as user name “root”, the password that you have chosen during the installation, “127.0.0.1” for the local IP address of the server and “3306” as port number. Now click on “Test” button to verify that the connection can be made.
The “Test” database is empty, so let’s create a test table there. Still in the the FireDAC connection editor window click on the “SQL Script” tab, where we can execute arbitrary SQL statements against the connected database. Execute “CREATE TABLE” statement to create a simple table called “TEST1” with an integer “Id” and varchar(50) “AName” columns. Execute script. You should get a message that it has executed OK.
If you expand the “Tables” node under the “test1” database node, you should see “test1” table created.
Right-click on the “Test1” table and you can enter some test data to the table.
That’s it. Now it is your turn to build a cool VCL or multi-device app that works with this MariaDB database!