Re: [Trac] Converting from sqlite to mariadb/mysql

Bruce Dubbs <[email protected]> Sun, 8 Feb 2026 21:44:50 -0800 (PST)
Newsgroups gmane.comp.version-control.subversion.trac.general
Message-ID <[email protected]>
------=_Part_158306_693393511.1770615890692
Content-Type: multipart/alternative; 
	boundary="----=_Part_158307_1672614187.1770615890692"

------=_Part_158307_1672614187.1770615890692
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

This is just to close out the problem above. We now have Trac working with=
=20
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 =3D False

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

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

We had originally installed the database with sqlite3mysql. That must be an=
=20
old application because Trac did not like the format. Using trac-admin=20
fixed that.
On Friday, February 6, 2026 at 12:15:12=E2=80=AFPM UTC-6 Bruce Dubbs wrote:

> On 2/6/26 12:43 AM, Jun Omae wrote:
> > On 2026/02/06 12:30, Bruce Dubbs wrote:
> >> On 2/5/26 8:39 PM, Jun Omae wrote:
> >>> Hi,
> >>>
> >>> On Fri, Feb 6, 2026 at 10:37=E2=80=AFAM Bruce Dubbs <[email protected]=
om>=20
> wrote:
> >>>>
> >>>> At the linuxfromscratch project we have been using Trac for a very=
=20
> long time. The last time we updated Trac was in 2021 using the latest=20
> development system at that time. Over the years our sqlite databases have=
=20
> grown quite large: 287M, 884M, and 642M respectively.
> >>>>
> >>>> We have noticed some response problems and want to update to the=20
> latest Trac and convert to mariadb.
> >>>>
> >>>> Doing some testing on a test server we installed python3.13,=20
> Trac-1.6, PyMySQL, and mariadb-11.8.5. We then copied a current trac.db t=
o=20
> 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 al=
l=20
> looks good. We do have a symlink /usr/bin/mysql -> mariadb
> >>>>
> >>>> We then edited the trac.ini file to read:
> >>>>
> >>>> #[sqlite]
> >>>> #extensions =3D
> >>>> ...
> >>>> [trac]
> >>>> ...
> >>>> #database =3D sqlite:db/trac.db
> >>>> #database =3D=20
> mysql://tracuser:password/trac_db?unix_socket=3D/run/mariadb/
> >>>> mariadb.sock
> >>>> database =3D mysql://tracuser:password@localhost/trac_db
> >>>>
> >>>> but no matter what we try after restarting apache get the error=20
> message:
> >>>>
> >>>> TracError: Unable to check for upgrade of=20
> trac.db.api.DatabaseManager: TracError: Unsupported database type "mysql"
> >>>>
> >>>> What are we missing?
> >>>
> >>> I'd suggest to check errors in trac.log. The pymysql library is
> >>> required for MySQL but it is unavailable in your environment.
> >>
> >> 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=20
> mysql://tracuser:password@localhost/trac_db
> >>
> >> But got the following:
> >>
> >> /usr/lib/python3.13/site-packages/trac/__init__.py:14: UserWarning:=20
> pkg_resources is
> >> deprecated as an API. See=20
> https://setuptools.pypa.io/en/latest/pkg_resources.html.
> >> The pkg_resources package is slated for removal as early as 2025-11-30=
.=20
> 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:=20
> TimeoutError:
> >> Unable to get database connection within 10 seconds.
> >=20
> > I guess it is failing to connect to the database via TCP. Please check
> > connecting to the database via TCP connection using mariadb client.
> >=20
> >> #database =3D mysql://tracuser:password/trac_db?unix_socket=3D/run/mar=
iadb/
> >> mariadb.sock
> >=20
> > If you want to use unix domain socket, use like the following ("@"=20
> character is
> > needed after the password):
> >=20
> > mysql://tracuser:password@/trac_db?unix_socket=3D/run/mariadb/mariadb.s=
ock
>
> I had tried that earlier, but I did not have the @ after the password. I=
=20
> set that up=20
> and restarted apache, but still got two errors in the log (slightly=20
> formatted for=20
> 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=
=20
> with
> database =3D 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.=
=20
> It does=20
> work if I revert to sqlite.
>
> What can I try next?
>
>

--=20
You received this message because you are subscribed to the Google Groups "=
Trac Users" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to trac-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
To view this discussion visit https://groups.google.com/d/msgid/trac-users/=
4dcf4a33-f6ee-4775-bad7-a627ea919fe7n%40googlegroups.com.

------=_Part_158307_1672614187.1770615890692
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div>This is just to close out the problem above. We now have Trac working =
with mariadb.</div><div>=C2=A0We needed to do two things:</div><br />First =
we needed to modify our &lt;instance&gt;.wsgi file to add:<br /><br />    i=
mport trac.db.mysql_backend<br />    trac.db.mysql_backend.MySQLConnection.=
poolable =3D False<br /><br />For some reason the database could not be fou=
nd without the explicit import.=C2=A0<br />In the second line we wanted to =
prevent "too many connections" errors.<br /><br />Second, we rebuilt the da=
tabase with <br />  trac-admin /srv/trac/lfs convert_db "mysql://tracuser:p=
assword@localhost/tracdb"'<br /><br />We had originally installed the datab=
ase with=C2=A0<span style=3D"white-space: pre-wrap;">sqlite3mysql.  That mu=
st be an old application because Trac did not like the format.  Using trac-=
admin fixed that.</span><div class=3D"gmail_quote"><div dir=3D"auto" class=
=3D"gmail_attr">On Friday, February 6, 2026 at 12:15:12=E2=80=AFPM UTC-6 Br=
uce Dubbs wrote:<br/></div><blockquote class=3D"gmail_quote" style=3D"margi=
n: 0 0 0 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1e=
x;">On 2/6/26 12:43 AM, Jun Omae wrote:
<br>&gt; On 2026/02/06 12:30, Bruce Dubbs wrote:
<br>&gt;&gt; On 2/5/26 8:39 PM, Jun Omae wrote:
<br>&gt;&gt;&gt; Hi,
<br>&gt;&gt;&gt;
<br>&gt;&gt;&gt; On Fri, Feb 6, 2026 at 10:37=E2=80=AFAM Bruce Dubbs &lt;<a=
 href data-email-masked rel=3D"nofollow">[email protected]</a>&gt; wrote:
<br>&gt;&gt;&gt;&gt;
<br>&gt;&gt;&gt;&gt; At the linuxfromscratch project we have been using Tra=
c for a very long time.  The last time we updated Trac was in 2021 using th=
e latest development system at that time.  Over the years our sqlite databa=
ses have grown quite large: 287M, 884M, and 642M respectively.
<br>&gt;&gt;&gt;&gt;
<br>&gt;&gt;&gt;&gt; We have noticed some response problems and want to upd=
ate to the latest Trac and convert to mariadb.
<br>&gt;&gt;&gt;&gt;
<br>&gt;&gt;&gt;&gt; Doing some testing on a test server we installed pytho=
n3.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 mariad=
b.
<br>&gt;&gt;&gt;&gt;
<br>&gt;&gt;&gt;&gt; We can log into mariadb with  &#39;mariadb -u tracuser=
 -p trac_db&#39; and all looks good.  We do have a symlink  /usr/bin/mysql =
-&gt; mariadb
<br>&gt;&gt;&gt;&gt;
<br>&gt;&gt;&gt;&gt; We then edited the  trac.ini file to read:
<br>&gt;&gt;&gt;&gt;
<br>&gt;&gt;&gt;&gt; #[sqlite]
<br>&gt;&gt;&gt;&gt; #extensions =3D
<br>&gt;&gt;&gt;&gt; ...
<br>&gt;&gt;&gt;&gt; [trac]
<br>&gt;&gt;&gt;&gt; ...
<br>&gt;&gt;&gt;&gt; #database =3D sqlite:db/trac.db
<br>&gt;&gt;&gt;&gt; #database =3D mysql://tracuser:password/trac_db?unix_s=
ocket=3D/run/mariadb/
<br>&gt;&gt;&gt;&gt;       mariadb.sock
<br>&gt;&gt;&gt;&gt; database =3D mysql://tracuser:password@localhost/trac_=
db
<br>&gt;&gt;&gt;&gt;
<br>&gt;&gt;&gt;&gt; but no matter what we try after restarting apache get =
the error message:
<br>&gt;&gt;&gt;&gt;
<br>&gt;&gt;&gt;&gt; TracError: Unable to check for upgrade of trac.db.api.=
DatabaseManager: TracError: Unsupported database type &quot;mysql&quot;
<br>&gt;&gt;&gt;&gt;
<br>&gt;&gt;&gt;&gt; What are we missing?
<br>&gt;&gt;&gt;
<br>&gt;&gt;&gt; I&#39;d suggest to check errors in trac.log. The pymysql l=
ibrary is
<br>&gt;&gt;&gt; required for MySQL but it is unavailable in your environme=
nt.
<br>&gt;&gt;
<br>&gt;&gt; I did look at trac.log.  It just says the error message above.
<br>&gt;&gt; I also said above that pymysql is installed.  I checked with:
<br>&gt;&gt;
<br>&gt;&gt; $ python3
<br>&gt;&gt; Python 3.13.7 (main, Feb  3 2026, 16:47:05) [GCC 15.2.0] on li=
nux
<br>&gt;&gt; Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&qu=
ot; or &quot;license&quot; for more information.
<br>&gt;&gt;   &gt;&gt;&gt; import pymysql
<br>&gt;&gt;
<br>&gt;&gt; without error.
<br>&gt;&gt;
<br>&gt;&gt; I tried the following:
<br>&gt;&gt;
<br>&gt;&gt; trac-admin /srv/trac/lfs convert_db mysql://tracuser:password@=
localhost/trac_db
<br>&gt;&gt;
<br>&gt;&gt; But got the following:
<br>&gt;&gt;
<br>&gt;&gt; /usr/lib/python3.13/site-packages/trac/__init__.py:14: UserWar=
ning: pkg_resources is
<br>&gt;&gt; deprecated as an API. See <a href=3D"https://setuptools.pypa.i=
o/en/latest/pkg_resources.html" target=3D"_blank" rel=3D"nofollow" data-saf=
eredirecturl=3D"https://www.google.com/url?hl=3Den&amp;q=3Dhttps://setuptoo=
ls.pypa.io/en/latest/pkg_resources.html&amp;source=3Dgmail&amp;ust=3D177070=
1813838000&amp;usg=3DAOvVaw2LrFIL8BbGXx_pmR7NKvQu">https://setuptools.pypa.=
io/en/latest/pkg_resources.html</a>.
<br>&gt;&gt; The pkg_resources package is slated for removal as early as 20=
25-11-30. Refrain from
<br>&gt;&gt; using this package or pin to Setuptools&lt;81.
<br>&gt;&gt;
<br>&gt;&gt;     from pkg_resources import DistributionNotFound, get_distri=
bution
<br>&gt;&gt; Error: Unable to check for upgrade of trac.db.api.DatabaseMana=
ger: TimeoutError:
<br>&gt;&gt; Unable to get database connection within 10 seconds.
<br>&gt;=20
<br>&gt; I guess it is failing to connect to the database via TCP. Please c=
heck
<br>&gt; connecting to the database via TCP connection using mariadb client=
.
<br>&gt;=20
<br>&gt;&gt; #database =3D mysql://tracuser:password/trac_db?unix_socket=3D=
/run/mariadb/
<br>&gt;&gt;      mariadb.sock
<br>&gt;=20
<br>&gt; If you want to use unix domain socket, use like the following (&qu=
ot;@&quot; character is
<br>&gt; needed after the password):
<br>&gt;=20
<br>&gt;    mysql://tracuser:password@/trac_db?unix_socket=3D/run/mariadb/m=
ariadb.sock
<br>
<br>I had tried that earlier, but I did not have the @ after the password. =
 I set that up=20
<br>and restarted apache, but still got two errors in the log (slightly for=
matted for=20
<br>spacing):
<br>
<br>2026-02-06 11:44:29,086 Trac[env]
<br>ERROR: Exception caught while checking for upgrade:
<br>   TracError: Unable to check for upgrade of trac.db.api.DatabaseManage=
r:
<br>   TracError: Unsupported database type &quot;mysql&quot;
<br>
<br>I also rechecked that mariadb/mysql is listening at port 3306 and retri=
ed with
<br>   database =3D mysql://tracuser:password@localhost/trac_db
<br>and got the same answer.
<br>
<br>To me it appears that Trac is not even trying to connect to the databas=
e.  It does=20
<br>work if I revert to sqlite.
<br>
<br>What can I try next?
<br>
<br></blockquote></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;Trac Users&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:trac-users+unsubscribe-/[email protected]">trac-use=
rs+unsubscribe-/[email protected]</a>.<br />
To view this discussion visit <a href=3D"https://groups.google.com/d/msgid/=
trac-users/4dcf4a33-f6ee-4775-bad7-a627ea919fe7n%40googlegroups.com?utm_med=
ium=3Demail&utm_source=3Dfooter">https://groups.google.com/d/msgid/trac-use=
rs/4dcf4a33-f6ee-4775-bad7-a627ea919fe7n%40googlegroups.com</a>.<br />

------=_Part_158307_1672614187.1770615890692--

------=_Part_158306_693393511.1770615890692--