Converting from sqlite to mariadb/mysql

18 views
Skip to first unread message

Bruce Dubbs

unread,
Feb 5, 2026, 8:37:14 PM (4 days ago) Feb 5
to Trac Users
At the linuxfromscratch project we have been using Trac for a very long time.  The last time we updated Trac was in 2021 using the latest development system at that time.  Over the years our sqlite databases have grown quite large: 287M, 884M, and 642M respectively.

We have noticed some response problems and want to update to the latest Trac and convert to mariadb.

Doing some testing on a test server we installed python3.13, Trac-1.6, PyMySQL, and mariadb-11.8.5. We then copied a current trac.db to the test system and ran sqlite3mysql to copy the trac.db into mariadb.  

We can log into mariadb with  'mariadb -u tracuser -p trac_db' and all looks good.  We do have a symlink  /usr/bin/mysql -> mariadb

We then edited the  trac.ini file to read:

#[sqlite]
#extensions = 
...
[trac]
...
#database = sqlite:db/trac.db
#database = mysql://tracuser:password/trac_db?unix_socket=/run/mariadb/
    mariadb.sock
database = mysql://tracuser:password@localhost/trac_db

but no matter what we try after restarting apache get the error message:

TracError: Unable to check for upgrade of trac.db.api.DatabaseManager: TracError: Unsupported database type "mysql"

What are we missing?

Jun Omae

unread,
Feb 5, 2026, 9:40:08 PM (4 days ago) Feb 5
to trac-...@googlegroups.com
Hi,
I'd suggest to check errors in trac.log. The pymysql library is
required for MySQL but it is unavailable in your environment.

See also: https://trac.edgewall.org/wiki/SqLiteToMySql

--
Jun Omae <jun...@gmail.com> (大前 潤)

Bruce Dubbs

unread,
Feb 5, 2026, 10:30:53 PM (4 days ago) Feb 5
to trac-...@googlegroups.com
I did look at trac.log. It just says the error message above.
I also said above that pymysql is installed. I checked with:

$ python3
Python 3.13.7 (main, Feb 3 2026, 16:47:05) [GCC 15.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pymysql

without error.

I tried the following:

trac-admin /srv/trac/lfs convert_db mysql://tracuser:password@localhost/trac_db

But got the following:

/usr/lib/python3.13/site-packages/trac/__init__.py:14: UserWarning: pkg_resources is
deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html.
The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from
using this package or pin to Setuptools<81.

from pkg_resources import DistributionNotFound, get_distribution
Error: Unable to check for upgrade of trac.db.api.DatabaseManager: TimeoutError:
Unable to get database connection within 10 seconds.

> See also: https://trac.edgewall.org/wiki/SqLiteToMySql
I did but it did not help

By the way, this is a linuxfromscratch build. The above indicates to me that it is
looking for some commercial distribution like Debian or Fedora. I suspect I need some
more detailed advice.


Jun Omae

unread,
Feb 6, 2026, 1:43:50 AM (4 days ago) Feb 6
to trac-...@googlegroups.com
I guess it is failing to connect to the database via TCP. Please check
connecting to the database via TCP connection using mariadb client.

> #database = mysql://tracuser:password/trac_db?unix_socket=/run/mariadb/
> mariadb.sock

If you want to use unix domain socket, use like the following ("@" character is
needed after the password):

mysql://tracuser:password@/trac_db?unix_socket=/run/mariadb/mariadb.sock

Bruce Dubbs

unread,
Feb 6, 2026, 1:15:12 PM (3 days ago) Feb 6
to trac-...@googlegroups.com
I had tried that earlier, but I did not have the @ after the password. I set that up
and restarted apache, but still got two errors in the log (slightly formatted for
spacing):

2026-02-06 11:44:29,086 Trac[env]
ERROR: Exception caught while checking for upgrade:
TracError: Unable to check for upgrade of trac.db.api.DatabaseManager:
TracError: Unsupported database type "mysql"

I also rechecked that mariadb/mysql is listening at port 3306 and retried with
database = mysql://tracuser:password@localhost/trac_db
and got the same answer.

To me it appears that Trac is not even trying to connect to the database. It does
work if I revert to sqlite.

What can I try next?

Bruce Dubbs

unread,
12:44 AM (16 hours ago) 12:44 AM
to Trac Users
This is just to close out the problem above. We now have Trac working with mariadb.
 We needed to do two things:

First we needed to modify our <instance>.wsgi file to add:

import trac.db.mysql_backend
trac.db.mysql_backend.MySQLConnection.poolable = False

For some reason the database could not be found without the explicit import. 
In the second line we wanted to prevent "too many connections" errors.

Second, we rebuilt the database with
trac-admin /srv/trac/lfs convert_db "mysql://tracuser:password@localhost/tracdb"'

We had originally installed the database with sqlite3mysql. That must be an old application because Trac did not like the format. Using trac-admin fixed that.
Reply all
Reply to author
Forward
0 new messages