question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MySQL Connect Issues

See original GitHub issue

Using Ubuntu 20.04 (LXC VM)

Papermerge works fine with SQLite as the backend database but when changing the configuration to MySQL/MariaDB it doesn’t connect.

papermerge.conf.py DBTYPE = “mysql” DBUSER = “pm” DBHOST = “localhost” DBNAME = “pm” DBPORT = “3306” DBPASS = “pm”

Error when trying to migrate:

Traceback (most recent call last):
  File "/root/papermerge/.venv/lib/python3.8/site-packages/django/db/backends/base/base.py", line 220, in ensure_connection
    self.connect()
  File "/root/papermerge/.venv/lib/python3.8/site-packages/django/utils/asyncio.py", line 26, in inner
    return func(*args, **kwargs)
  File "/root/papermerge/.venv/lib/python3.8/site-packages/django/db/backends/base/base.py", line 197, in connect
    self.connection = self.get_new_connection(conn_params)
  File "/root/papermerge/.venv/lib/python3.8/site-packages/django/utils/asyncio.py", line 26, in inner
    return func(*args, **kwargs)
  File "/root/papermerge/.venv/lib/python3.8/site-packages/django/db/backends/postgresql/base.py", line 185, in get_new_connection
    connection = Database.connect(**conn_params)
  File "/usr/lib/python3/dist-packages/psycopg2/__init__.py", line 126, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: could not connect to server: Connection refused
        Is the server running on host "localhost" (::1) and accepting
        TCP/IP connections on port 3306?
received invalid response to SSL negotiation: j


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "./manage.py", line 24, in <module>
    execute_from_command_line(sys.argv)
  File "/root/papermerge/.venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "/root/papermerge/.venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/root/papermerge/.venv/lib/python3.8/site-packages/django/core/management/base.py", line 328, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/root/papermerge/.venv/lib/python3.8/site-packages/django/core/management/base.py", line 369, in execute
    output = self.handle(*args, **options)
  File "/root/papermerge/.venv/lib/python3.8/site-packages/django/core/management/base.py", line 83, in wrapped
    res = handle_func(*args, **kwargs)
  File "/root/papermerge/.venv/lib/python3.8/site-packages/django/core/management/commands/migrate.py", line 86, in handle
    executor = MigrationExecutor(connection, self.migration_progress_callback)
  File "/root/papermerge/.venv/lib/python3.8/site-packages/django/db/migrations/executor.py", line 18, in __init__
    self.loader = MigrationLoader(self.connection)
  File "/root/papermerge/.venv/lib/python3.8/site-packages/django/db/migrations/loader.py", line 49, in __init__
    self.build_graph()
  File "/root/papermerge/.venv/lib/python3.8/site-packages/django/db/migrations/loader.py", line 212, in build_graph
    self.applied_migrations = recorder.applied_migrations()
  File "/root/papermerge/.venv/lib/python3.8/site-packages/django/db/migrations/recorder.py", line 76, in applied_migrations
    if self.has_table():
  File "/root/papermerge/.venv/lib/python3.8/site-packages/django/db/migrations/recorder.py", line 56, in has_table
    return self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor())
  File "/root/papermerge/.venv/lib/python3.8/site-packages/django/utils/asyncio.py", line 26, in inner
    return func(*args, **kwargs)
  File "/root/papermerge/.venv/lib/python3.8/site-packages/django/db/backends/base/base.py", line 260, in cursor
    return self._cursor()
  File "/root/papermerge/.venv/lib/python3.8/site-packages/django/db/backends/base/base.py", line 236, in _cursor
    self.ensure_connection()
  File "/root/papermerge/.venv/lib/python3.8/site-packages/django/utils/asyncio.py", line 26, in inner
    return func(*args, **kwargs)
  File "/root/papermerge/.venv/lib/python3.8/site-packages/django/db/backends/base/base.py", line 220, in ensure_connection
    self.connect()
  File "/root/papermerge/.venv/lib/python3.8/site-packages/django/db/utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/root/papermerge/.venv/lib/python3.8/site-packages/django/db/backends/base/base.py", line 220, in ensure_connection
    self.connect()
  File "/root/papermerge/.venv/lib/python3.8/site-packages/django/utils/asyncio.py", line 26, in inner
    return func(*args, **kwargs)
  File "/root/papermerge/.venv/lib/python3.8/site-packages/django/db/backends/base/base.py", line 197, in connect
    self.connection = self.get_new_connection(conn_params)
  File "/root/papermerge/.venv/lib/python3.8/site-packages/django/utils/asyncio.py", line 26, in inner
    return func(*args, **kwargs)
  File "/root/papermerge/.venv/lib/python3.8/site-packages/django/db/backends/postgresql/base.py", line 185, in get_new_connection
    connection = Database.connect(**conn_params)
  File "/usr/lib/python3/dist-packages/psycopg2/__init__.py", line 126, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError: could not connect to server: Connection refused
        Is the server running on host "localhost" (::1) and accepting
        TCP/IP connections on port 3306?
received invalid response to SSL negotiation: j
  • I’ve tried running via localhost & an external MySQL database to confirm it wasn’t a specific issue with the MySQL installation.
  • I’ve confirmed being able to access both databases/tables with the credentials with mysql client via CLI

Any help would be greatly appreciated!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
doughnetcommented, Feb 5, 2021

I tried with Postgres and it worked fine. Can’t wait for the MySQL fix.

2reactions
ciurcommented, Feb 3, 2021

I see in provided error messages that Papermerge thinks it deals with PostgreSQL database. It looks like it ignores DBTYPE = "mysql" configuration.

It is definitely not an SSL issue.

Thank you for reporting this issue!

Read more comments on GitHub >

github_iconTop Results From Across the Web

6.2.22 Troubleshooting Problems Connecting to MySQL
Make sure that the server has not been configured to ignore network connections or (if you are attempting to connect remotely) that it...
Read more >
MySQL Connection Errors - Troubleshooting Information for ...
MySQL Connection Errors Troubleshooting Information · 1. The MySQL Server is not Running · 2. The MySQL server is not listening on the...
Read more >
Troubleshooting MySQL Connection Errors - KnownHost
Another possible cause is that there could be invalid or mismatched credentials in the site's database configuration file as compared to those ...
Read more >
12 most common MySQL errors you should be aware of
The lost connection to MySQL server error can occur because of one of the three likely causes explained in this section.
Read more >
Troubleshooting MySQL Database Connection Issues
Troubleshooting MySQL Database Connection Issues · Step 1: Configure Database User. To reconfigure your website's database settings, you will need to create a ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found