mediadc icon indicating copy to clipboard operation
mediadc copied to clipboard

Can't connect to Database (MariaDB, Docker)

Open Bennneeeet opened this issue 3 years ago • 5 comments
trafficstars

I've got an error during the installation / installation check.

I'm using:

  • Docker
  • Nextcloud 23.0.0
  • MariaDB 10.5
  • Media DC 0.1.8

That all runs on a Raspberry Pi 4B 8GB with a Ubuntu Server environment.

I've already looked through some issues here, but can't find a "simple" solution. So I think(hope that this issue can help others too.

That is the error log in the UI of Media DC: Screenshot 2022-01-12 at 14 01 22

 Configuration errors

db_exception_handler:

Traceback (most recent call last):

  File "/var/www/html/custom_apps/mediadc/lib/Service/python/db/pymysql/connections.py", line 602, in connect

    sock.connect(self.unix_socket)

ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File "/var/www/html/custom_apps/mediadc/lib/Service/python/db/connectors.py", line 37, in create_connection

    connection = pymysql.connect(unix_socket=config['usock'],

  File "/var/www/html/custom_apps/mediadc/lib/Service/python/db/pymysql/connections.py", line 352, in __init__

    self.connect()

  File "/var/www/html/custom_apps/mediadc/lib/Service/python/db/pymysql/connections.py", line 664, in connect

    raise exc

db.pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)")

Cant connect to database.

The database container looks like the following:

19b785dc4569    |     mariadb:10.5    |    "docker-entrypoint.s…"    |    4 days ago    |    Up 4 days    |    3306/tcp    |    db_1

My dbport in my nextcloud config.php is empty (#11):

'dbport' => '',

Bennneeeet avatar Jan 12 '22 13:01 Bennneeeet

@Bennneeeet can you show value(not a real one, you can replace it with xxx or some random, just to understand) for dbhost Looks like a bug in parsing code, it tries to use unix socket when must use network connection....

bigcat88 avatar Jan 12 '22 13:01 bigcat88

@bigcat88 sure:

'dbhost' => 'db_nc',

Bennneeeet avatar Jan 12 '22 13:01 Bennneeeet

@Bennneeeet can you comment line 101 in file MediaDC/lib/Service/python/db/manager.py and check will it helps with db connect?

This one in dev branch(in 0.1.8 store version it is line 101): https://github.com/andrey18106/mediadc/blob/d60203b272e311c0399dc0db108cd3dfeceb02ff/lib/Service/python/db/manager.py#L102

from this: config['dbhost'] = '' to this: # config['dbhost'] = ''

image

bigcat88 avatar Jan 12 '22 14:01 bigcat88

With this change it works. No errors occurred when checking the installation, and a test task also ran well. 👍

Great and fast support/hot fix - thank you.

Bennneeeet avatar Jan 12 '22 14:01 Bennneeeet

For other who will face the same problem, you can fix it with changing sources till update or add a port to dbhost, like this: 'dbhost' => 'db_nc:3306'

bigcat88 avatar Jan 12 '22 15:01 bigcat88