Connection to Mariadb failed

I am trying to use mariadb for the first time on my MacOS system but having some difficulty in connection.

I have installed mariadb and created the database as they are available in commad prompt:

    Mortozas-iMac:~ mak$ sudo /usr/local/mariadb/server/bin/mariadb
Password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.0.38-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| inteaccerp         |
| mysql              |
| performance_schema |
| test               |
+--------------------+
5 rows in set (0.00 sec) 

Then created user as follows:

    CREATE USER 'mortoza' IDENTIFIED BY 'xxxx';

    MariaDB [mysql]> grant USAGE ON *.* to 'mortoza'@'%' IDENTIFIED BY 'xxxx'; 
Query OK, 0 rows affected (0.00 sec)

MariaDB [mysql]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

Checked the GRANTS on the database as follows:

    MariaDB [mysql]> show grants for 'mortoza'@localhost;
+----------------------------------------------------------------------------------------------------------------+
| Grants for mortoza@localhost                                                                                   |
+----------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'mortoza'@'localhost' IDENTIFIED BY PASSWORD '*71A423EE610B82E6695F355B08DD252520BF3E0A' |
| GRANT ALL PRIVILEGES ON `inteaccerp`.* TO 'mortoza'@'localhost'                                                |
+----------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

Now Trying to connect from CUBA Studio that didn’t work.

image

When I test the connection I am getting the following error:

java.sql.SQLNonTransientConnectionException: Could not connect to address=(host=localhost)(port=3306)(type=master) : Connection refused (Connection refused)

This connection failure could be originated from either the mariadb setup or connection setup problem in the studio, thanks for your help anyway.

Hi @mortozakhan
‘Test connection’ invokes java.sql.DriverManager.getConnection(String url, Properties info). The connection is shown ‘successful’ if no exceptions were thrown. It is a standard way, and the implemented in Studio logic does not modify it.
I have tried to reproduce your case on my database and got the same result: “Failed to connect”.
So it seems ‘USAGE’ ON *.* grants are not enough.

  1. Try to test connection to your ‘inteaccerp’ database. As I see ‘mortoza’ has all grants to the database.
  2. Try to test connection under ‘root’ credentials.

Regards.

Hi Rostislav
Thanks. I tried both recommendations but same no connection!

Here is the print of users:

   MariaDB [(none)]> select host, user, password from mysql.user;
+-----------+---------+-------------------------------------------+
| host      | user    | password                                  |
+-----------+---------+-------------------------------------------+
| localhost | mak     | *E968C52D7F7637CA1791EDE0C500C928CAF2F3AD |
| localhost | root    |                                           |
| localhost | mortoza | *71A423EE610B82E6695F355B08DD252520BF3E0A |
| %         | mak     | *E968C52D7F7637CA1791EDE0C500C928CAF2F3AD |
| %         | mortoza | *71A423EE610B82E6695F355B08DD252520BF3E0A |
+-----------+---------+-------------------------------------------+

Since I saw the root user password for localhost is empty, I run the following commands to update it.

MariaDB [inteaccerp]> UPDATE mysql.user SET authentication_string=PASSWORD("xxxx") WHERE User='root';
Query OK, 2 rows affected (0.01 sec)
Rows matched: 2  Changed: 2  Warnings: 0

MariaDB [inteaccerp]> FLUSH privileges;
Query OK, 0 rows affected (0.00 sec)

But I sitll see the root password for localhost is empty.

MariaDB [inteaccerp]> select host, user, password from mysql.user;
+-----------+---------+-------------------------------------------+
| host      | user    | password                                  |
+-----------+---------+-------------------------------------------+
| localhost | mak     | *E968C52D7F7637CA1791EDE0C500C928CAF2F3AD |
| localhost | root    |                                           |
| localhost | mortoza | *71A423EE610B82E6695F355B08DD252520BF3E0A |
| %         | mak     | *E968C52D7F7637CA1791EDE0C500C928CAF2F3AD |
| %         | mortoza | *71A423EE610B82E6695F355B08DD252520BF3E0A |
+-----------+---------+-------------------------------------------+
6 rows in set (0.00 sec)

Then tried to connect using user mortoza, unfortunately the connection is failed. I also tried using root with empty password but still the same! Is problem lying here?

FYI, I followed this link to install MariaDb and wondering if there is any issue coming from the way it is installed. Do you suggest any methodology installing the MariaDb in MacOs?