Migrate database from sqlite3 to mysql #14761

Open
opened 2025-11-02 11:22:17 -06:00 by GiteaMirror · 7 comments
Owner

Originally created by @ChristmasZCY on GitHub (Jul 15, 2025).

Feature Description

Hi!
The database I used at the beginning was sqlite3 because it was easy to deploy. As my databases increased, the original sqlite3 files became larger and larger, and the speed also became slower. I hope to migrate to mysql, but I don't know how to migrate. Is there a built-in tool?

Screenshots

No response

Originally created by @ChristmasZCY on GitHub (Jul 15, 2025). ### Feature Description Hi! The database I used at the beginning was sqlite3 because it was easy to deploy. As my databases increased, the original sqlite3 files became larger and larger, and the speed also became slower. I hope to migrate to mysql, but I don't know how to migrate. Is there a built-in tool? ### Screenshots _No response_
GiteaMirror added the type/proposal label 2025-11-02 11:22:17 -06:00
Author
Owner

@Linjieqiang commented on GitHub (Jul 15, 2025):

Image

Converting one database type to another is not a well-tested process and you may experience issues. It is better to choose the final database type at the type of the first installation. Be aware that SQLite does not scale; if you expect your instance to grow at a later time, you should choose another database type.

@Linjieqiang commented on GitHub (Jul 15, 2025): <img width="1008" height="435" alt="Image" src="https://github.com/user-attachments/assets/0b07815c-fcf4-40d2-a7a7-970c921aa26a" /> Converting one database type to another is not a well-tested process and you may experience issues. It is better to choose the final database type at the type of the first installation. Be aware that SQLite does not scale; if you expect your instance to grow at a later time, you should choose another database type.
Author
Owner

@ChristmasZCY commented on GitHub (Jul 15, 2025):

Thank you, sounds so sad.

Image Converting one database type to another is not a well-tested process and you may experience issues. It is better to choose the final database type at the type of the first installation. Be aware that SQLite does not scale; if you expect your instance to grow at a later time, you should choose another database type.
@ChristmasZCY commented on GitHub (Jul 15, 2025): Thank you, sounds so sad. > <img alt="Image" width="1008" height="435" src="https://private-user-images.githubusercontent.com/10217966/466337768-0b07815c-fcf4-40d2-a7a7-970c921aa26a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NTI1NjU1OTcsIm5iZiI6MTc1MjU2NTI5NywicGF0aCI6Ii8xMDIxNzk2Ni80NjYzMzc3NjgtMGIwNzgxNWMtZmNmNC00MGQyLWE3YTctOTcwYzkyMWFhMjZhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTA3MTUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwNzE1VDA3NDEzN1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPThjMTUxNjdhZjc4M2Q3Yzg5OWQ1OTY1ODhhYTE3ZGNiMDcxYjNmOWViZjVhMmNmOGVjOTNhYTJjZWY0OWY0YTMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.TYWgZh0TBcsed9hsXj1NajfPujr9lQAh8jrBNFf0CRE"> > Converting one database type to another is not a well-tested process and you may experience issues. It is better to choose the final database type at the type of the first installation. Be aware that SQLite does not scale; if you expect your instance to grow at a later time, you should choose another database type.
Author
Owner

@MelvinCou commented on GitHub (Jul 15, 2025):

It is possible, see https://docs.gitea.com/administration/backup-and-restore#using-gitea-dump-to-convert-database-types
But as said above, that's at your own risk

Or using raw sqlite dump features : https://stackoverflow.com/questions/18671/quick-easy-way-to-migrate-sqlite3-to-mysql

@MelvinCou commented on GitHub (Jul 15, 2025): It is possible, see https://docs.gitea.com/administration/backup-and-restore#using-gitea-dump-to-convert-database-types But as said above, that's at your own risk Or using raw sqlite dump features : https://stackoverflow.com/questions/18671/quick-easy-way-to-migrate-sqlite3-to-mysql
Author
Owner

@juleslagarde commented on GitHub (Jul 16, 2025):

@ChristmasZCY I'm curious. Using Gitea with SQLite, where did you see slowdowns ? Do you think, it's linked to the number of repos ? How many repos do you have ?

@juleslagarde commented on GitHub (Jul 16, 2025): @ChristmasZCY I'm curious. Using Gitea with SQLite, where did you see slowdowns ? Do you think, it's linked to the number of repos ? How many repos do you have ?
Author
Owner

@softengel commented on GitHub (Jul 16, 2025):

@ChristmasZCY Maybe solve SQLite issues and then consider to migrate...

Some commands are your friend:
SQLITE_TMPDIR=. sqlite3 gitea.db VACUUM;
sqlite3 gitea.db "SELECT name ,SUM(pgsize)/1024 table_size FROM "dbstat" GROUP BY name ORDER BY table_size desc;" | less

For example if action is to big (app.ini):
[cron.delete_old_actions]
ENABLED = true
RUN_AT_START = true
NOTICE_ON_SUCCESS = true
SCHEDULE = @every 24h
OLDER_THAN = 144h

Better to migrate as less as possible.
And gitea will be much faster with small sqlite3 db.

@softengel commented on GitHub (Jul 16, 2025): @ChristmasZCY Maybe solve SQLite issues and then consider to migrate... Some commands are your friend: SQLITE_TMPDIR=. sqlite3 gitea.db VACUUM; sqlite3 gitea.db "SELECT name ,SUM(pgsize)/1024 table_size FROM "dbstat" GROUP BY name ORDER BY table_size desc;" | less For example if action is to big (app.ini): [cron.delete_old_actions] ENABLED = true RUN_AT_START = true NOTICE_ON_SUCCESS = true SCHEDULE = @every 24h OLDER_THAN = 144h Better to migrate as less as possible. And gitea will be much faster with small sqlite3 db.
Author
Owner

@ChristmasZCY commented on GitHub (Jul 17, 2025):

Sometimes, when I open a repo in web, It loads slow. As follows.
There is 3717 repos in my web.
The gitea.db file is 2.2G.

Image

@ChristmasZCY I'm curious. Using Gitea with SQLite, where did you see slowdowns ? Do you think, it's linked to the number of repos ? How many repos do you have ?我很好奇。将 Gitea 与 SQLite 一起使用,您在哪里看到速度变慢?你认为,它与 repos 的数量有关吗?您有多少个存储库 ?

@ChristmasZCY commented on GitHub (Jul 17, 2025): Sometimes, when I open a repo in web, It loads slow. As follows. There is 3717 repos in my web. The gitea.db file is 2.2G. <img width="1225" height="660" alt="Image" src="https://github.com/user-attachments/assets/94828941-5ab7-40f8-b7a4-c87b5c671184" /> > [@ChristmasZCY](https://github.com/ChristmasZCY) I'm curious. Using Gitea with SQLite, where did you see slowdowns ? Do you think, it's linked to the number of repos ? How many repos do you have ?我很好奇。将 Gitea 与 SQLite 一起使用,您在哪里看到速度变慢?你认为,它与 repos 的数量有关吗?您有多少个存储库 ?
Author
Owner

@ChristmasZCY commented on GitHub (Jul 17, 2025):

Thank you, I'll try it.

@ChristmasZCY Maybe solve SQLite issues and then consider to migrate...也许解决 SQLite 问题,然后考虑迁移......

Some commands are your friend:有些命令是你的朋友: SQLITE_TMPDIR=. sqlite3 gitea.db VACUUM;SQLITE_TMPDIR=。sqlite3 gitea.db 真空; sqlite3 gitea.db "SELECT name ,SUM(pgsize)/1024 table_size FROM "dbstat" GROUP BY name ORDER BY table_size desc;" | lesssqlite3 gitea.db “SELECT name ,SUM(pgsize)/1024 table_size FROM ”dbstat“ GROUP BY name ORDER BY table_size desc;” |少

For example if action is to big (app.ini):例如,如果 action 是 to big (app.ini): [cron.delete_old_actions] ENABLED = true  启用 = true RUN_AT_START = true  RUN_AT_START = 真 NOTICE_ON_SUCCESS = trueNOTICE_ON_SUCCESS = 真 SCHEDULE = @every 24h  时间表 = 24 小时 OLDER_THAN = 144h  OLDER_THAN = 144 小时

Better to migrate as less as possible.最好尽可能少地迁移。 And gitea will be much faster with small sqlite3 db.而 gitea 在小 sqlite3 db 时会快得多。

It is possible, see https://docs.gitea.com/administration/backup-and-restore#using-gitea-dump-to-convert-database-types这是可能的,请参阅 https://docs.gitea.com/administration/backup-and-restore#using-gitea-dump-to-convert-database-types But as said above, that's at your own risk但如上所述,这是您自己承担的风险

Or using raw sqlite dump features : https://stackoverflow.com/questions/18671/quick-easy-way-to-migrate-sqlite3-to-mysql或使用原始 sqlite 转储功能:https://stackoverflow.com/questions/18671/quick-easy-way-to-migrate-sqlite3-to-mysql

@ChristmasZCY commented on GitHub (Jul 17, 2025): Thank you, I'll try it. > [@ChristmasZCY](https://github.com/ChristmasZCY) Maybe solve SQLite issues and then consider to migrate...也许解决 SQLite 问题,然后考虑迁移...... > > Some commands are your friend:有些命令是你的朋友: SQLITE_TMPDIR=. sqlite3 gitea.db VACUUM;SQLITE_TMPDIR=。sqlite3 gitea.db 真空; sqlite3 gitea.db "SELECT name ,SUM(pgsize)/1024 table_size FROM "dbstat" GROUP BY name ORDER BY table_size desc;" | lesssqlite3 gitea.db “SELECT name ,SUM(pgsize)/1024 table_size FROM ”dbstat“ GROUP BY name ORDER BY table_size desc;” |少 > > For example if action is to big (app.ini):例如,如果 action 是 to big (app.ini): [cron.delete_old_actions] ENABLED = true  启用 = true RUN_AT_START = true  RUN_AT_START = 真 NOTICE_ON_SUCCESS = trueNOTICE_ON_SUCCESS = 真 SCHEDULE = [@every](https://github.com/every) 24h  时间表 = 24 小时 OLDER_THAN = 144h  OLDER_THAN = 144 小时 > > Better to migrate as less as possible.最好尽可能少地迁移。 And gitea will be much faster with small sqlite3 db.而 gitea 在小 sqlite3 db 时会快得多。 > It is possible, see https://docs.gitea.com/administration/backup-and-restore#using-gitea-dump-to-convert-database-types这是可能的,请参阅 https://docs.gitea.com/administration/backup-and-restore#using-gitea-dump-to-convert-database-types But as said above, that's at your own risk但如上所述,这是您自己承担的风险 > > Or using raw sqlite dump features : https://stackoverflow.com/questions/18671/quick-easy-way-to-migrate-sqlite3-to-mysql或使用原始 sqlite 转储功能:https://stackoverflow.com/questions/18671/quick-easy-way-to-migrate-sqlite3-to-mysql
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#14761