Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't connect to MySQL via TCP, I need to use UNIX socket #11707

Closed
2 of 7 tasks
AlphaJack opened this issue May 31, 2020 · 7 comments
Closed
2 of 7 tasks

Can't connect to MySQL via TCP, I need to use UNIX socket #11707

AlphaJack opened this issue May 31, 2020 · 7 comments
Labels
issue/not-a-bug The reported issue is the intended behavior or the problem is not inside Gitea

Comments

@AlphaJack
Copy link

  • Gitea version (or commit ref): Gitea version 1.11.0 built with GNU Make 4.3, go1.13.8 : bindata, sqlite, pam

  • Git version: git 2.26.2-1

  • Operating system: Linux 5.4.40-1-ARCH #1 SMP PREEMPT Thu May 14 01:48:56 UTC 2020 armv7l GNU/Linux

  • Database (use [x]):

    • PostgreSQL
    • MySQL mariadb 10.4.13-1
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:

    • Yes (provide example URL)
    • No
    • Not relevant

Description

I tried to move to MySQL after the some time using SQLite. I did

sudo -u gitea gitea dump -d mysql -c /etc/gitea/app.ini
sudo mariadb -u root

On the DB shell,

CREATE DATABASE gitea-db;
CREATE USER 'gitea'@'localhost' IDENTIFIED BY 'XXXXXX';
GRANT ALL ON gitea-db.* TO 'gitea'@'localhost' IDENTIFIED BY 'XXXXXX' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;

Again in bash

mysql -u gitea -p gitea-db < gitea-db.sql 

The command exited without errors. I stopped Gitea and changed in app,ini from this

[Database]
DB_TYPE = sqlite3 
HOST =
NAME =
USER =
PASSWD =
SSL_MODE = disable

to this

DB_TYPE             = mysql
HOST                = localhost
NAME                = gitea-db
USER                = gitea
PASSWD              = XXXXXX
SSL_MODE            = false
CHARSET             = utf8mb4

ITERATE_BUFFER_SIZE = 50
; Show the database generated SQL
LOG_SQL             = false
; Maximum number of DB Connect retries
DB_RETRIES          = 10
; Backoff time per DB retry (time.Duration)
DB_RETRY_BACKOFF    = 3s
; Max idle database connections on connnection pool, default is 2
MAX_IDLE_CONNS      = 2
; Database connection max life time, default is 0 or 3s mysql (See #6804 & #7071 for reasoning)
CONN_MAX_LIFETIME   = 3s
; Database maximum number of open connections, default is 0 meaning no maximum
MAX_OPEN_CONNS      = 0

When I tried to restart Gitea system service, it failed with result 'exit-code'. gitea.log reports:

`gitea.log`
2020/05/31 15:33:07 ...eful/manager_unix.go:133:handleSignals() [W] PID 549. Received SIGTERM. Shutting down...
2020/05/31 15:33:07 cmd/web.go:206:runWeb() [I] HTTP Listener: 127.0.0.1:3000 Closed
2020/05/31 15:33:07 ...eful/server_hooks.go:47:doShutdown() [I] PID: 549 Listener (127.0.0.1:3000) closed.
2020/05/31 15:33:07 ...rvices/pull/check.go:212:TestPullRequests() [I] PID: 549 Pull Request testing shutdown
2020/05/31 15:33:08 .../graceful/manager.go:184:doHammerTime() [W] Setting Hammer condition
2020/05/31 15:33:09 .../graceful/manager.go:198:doTerminate() [W] Terminating
2020/05/31 15:33:09 ...er/issues/indexer.go:161:1() [I] PID: 549 Issue Indexer closed
2020/05/31 15:33:09 cmd/web.go:208:runWeb() [I] PID: 549 Gitea Web Finished
2020/05/31 15:34:26 ...dules/setting/log.go:276:newLogService() [I] Gitea Log Mode: File(File:info)
2020/05/31 15:34:26 ...les/setting/cache.go:45:newCacheService() [I] Cache Service Enabled
2020/05/31 15:34:26 ...s/setting/session.go:44:newSessionService() [I] Session Service Enabled
2020/05/31 15:34:26 ...es/setting/mailer.go:106:newMailService() [I] Mail Service Enabled
2020/05/31 15:34:26 ...es/setting/mailer.go:117:newRegisterMailService() [I] Register Mail Service Enabled
2020/05/31 15:34:26 ...es/setting/mailer.go:128:newNotifyMailService() [I] Notify Mail Service Enabled
2020/05/31 15:34:26 routers/init.go:59:initDBEngine() [I] Beginning ORM engine initialization.
2020/05/31 15:34:26 routers/init.go:66:initDBEngine() [I] ORM engine initialization attempt #1/10...
2020/05/31 15:34:26 ...orm@v0.8.1/engine.go:351:Ping() [I] PING DATABASE mysql
2020/05/31 15:34:26 routers/init.go:72:initDBEngine() [E] ORM engine initialization attempt #1/10 failed. Error: commands out of sync. Did you run multiple statements at once?
2020/05/31 15:34:26 routers/init.go:73:initDBEngine() [I] Backing off for 3 seconds
2020/05/31 15:34:29 routers/init.go:66:initDBEngine() [I] ORM engine initialization attempt #2/10...
2020/05/31 15:34:29 ...orm@v0.8.1/engine.go:351:Ping() [I] PING DATABASE mysql
2020/05/31 15:34:29 routers/init.go:72:initDBEngine() [E] ORM engine initialization attempt #2/10 failed. Error: commands out of sync. Did you run multiple statements at once?
2020/05/31 15:34:29 routers/init.go:73:initDBEngine() [I] Backing off for 3 seconds
2020/05/31 15:34:32 routers/init.go:66:initDBEngine() [I] ORM engine initialization attempt #3/10...
2020/05/31 15:34:32 ...orm@v0.8.1/engine.go:351:Ping() [I] PING DATABASE mysql
2020/05/31 15:34:32 routers/init.go:72:initDBEngine() [E] ORM engine initialization attempt #3/10 failed. Error: commands out of sync. Did you run multiple statements at once?
2020/05/31 15:34:32 routers/init.go:73:initDBEngine() [I] Backing off for 3 seconds
2020/05/31 15:34:35 routers/init.go:66:initDBEngine() [I] ORM engine initialization attempt #4/10...
2020/05/31 15:34:35 ...orm@v0.8.1/engine.go:351:Ping() [I] PING DATABASE mysql
2020/05/31 15:34:35 routers/init.go:72:initDBEngine() [E] ORM engine initialization attempt #4/10 failed. Error: commands out of sync. Did you run multiple statements at once?
2020/05/31 15:34:35 routers/init.go:73:initDBEngine() [I] Backing off for 3 seconds
2020/05/31 15:34:38 routers/init.go:66:initDBEngine() [I] ORM engine initialization attempt #5/10...
2020/05/31 15:34:38 ...orm@v0.8.1/engine.go:351:Ping() [I] PING DATABASE mysql
2020/05/31 15:34:38 routers/init.go:72:initDBEngine() [E] ORM engine initialization attempt #5/10 failed. Error: commands out of sync. Did you run multiple statements at once?
2020/05/31 15:34:38 routers/init.go:73:initDBEngine() [I] Backing off for 3 seconds
2020/05/31 15:34:41 routers/init.go:66:initDBEngine() [I] ORM engine initialization attempt #6/10...
2020/05/31 15:34:41 ...orm@v0.8.1/engine.go:351:Ping() [I] PING DATABASE mysql
2020/05/31 15:34:41 routers/init.go:72:initDBEngine() [E] ORM engine initialization attempt #6/10 failed. Error: commands out of sync. Did you run multiple statements at once?
2020/05/31 15:34:41 routers/init.go:73:initDBEngine() [I] Backing off for 3 seconds
2020/05/31 15:34:44 routers/init.go:66:initDBEngine() [I] ORM engine initialization attempt #7/10...
2020/05/31 15:34:44 ...orm@v0.8.1/engine.go:351:Ping() [I] PING DATABASE mysql
2020/05/31 15:34:44 routers/init.go:72:initDBEngine() [E] ORM engine initialization attempt #7/10 failed. Error: commands out of sync. Did you run multiple statements at once?
2020/05/31 15:34:44 routers/init.go:73:initDBEngine() [I] Backing off for 3 seconds
2020/05/31 15:34:47 routers/init.go:66:initDBEngine() [I] ORM engine initialization attempt #8/10...
2020/05/31 15:34:47 ...orm@v0.8.1/engine.go:351:Ping() [I] PING DATABASE mysql
2020/05/31 15:34:47 routers/init.go:72:initDBEngine() [E] ORM engine initialization attempt #8/10 failed. Error: commands out of sync. Did you run multiple statements at once?
2020/05/31 15:34:47 routers/init.go:73:initDBEngine() [I] Backing off for 3 seconds
2020/05/31 15:34:50 routers/init.go:66:initDBEngine() [I] ORM engine initialization attempt #9/10...
2020/05/31 15:34:50 ...orm@v0.8.1/engine.go:351:Ping() [I] PING DATABASE mysql
2020/05/31 15:34:50 routers/init.go:72:initDBEngine() [E] ORM engine initialization attempt #9/10 failed. Error: commands out of sync. Did you run multiple statements at once?
2020/05/31 15:34:50 routers/init.go:73:initDBEngine() [I] Backing off for 3 seconds
2020/05/31 15:34:53 routers/init.go:66:initDBEngine() [I] ORM engine initialization attempt #10/10...
2020/05/31 15:34:53 ...orm@v0.8.1/engine.go:351:Ping() [I] PING DATABASE mysql
2020/05/31 15:34:53 routers/init.go:101:GlobalInit() [F] ORM engine initialization failed: commands out of sync. Did you run multiple statements at once?
2020/05/31 15:34:58 ...dules/setting/log.go:276:newLogService() [I] Gitea Log Mode: File(File:info)
2020/05/31 15:34:58 ...les/setting/cache.go:45:newCacheService() [I] Cache Service Enabled
2020/05/31 15:34:58 ...s/setting/session.go:44:newSessionService() [I] Session Service Enabled
2020/05/31 15:34:58 ...es/setting/mailer.go:106:newMailService() [I] Mail Service Enabled
2020/05/31 15:34:58 ...es/setting/mailer.go:117:newRegisterMailService() [I] Register Mail Service Enabled
2020/05/31 15:34:58 ...es/setting/mailer.go:128:newNotifyMailService() [I] Notify Mail Service Enabled
2020/05/31 15:34:58 routers/init.go:59:initDBEngine() [I] Beginning ORM engine initialization.
2020/05/31 15:34:58 routers/init.go:66:initDBEngine() [I] ORM engine initialization attempt #1/10...
2020/05/31 15:34:58 ...orm@v0.8.1/engine.go:351:Ping() [I] PING DATABASE mysql
2020/05/31 15:34:58 routers/init.go:72:initDBEngine() [E] ORM engine initialization attempt #1/10 failed. Error: commands out of sync. Did you run multiple statements at once?
2020/05/31 15:34:58 routers/init.go:73:initDBEngine() [I] Backing off for 3 seconds
2020/05/31 15:35:01 routers/init.go:66:initDBEngine() [I] ORM engine initialization attempt #2/10...
2020/05/31 15:35:01 ...orm@v0.8.1/engine.go:351:Ping() [I] PING DATABASE mysql
2020/05/31 15:35:01 routers/init.go:72:initDBEngine() [E] ORM engine initialization attempt #2/10 failed. Error: commands out of sync. Did you run multiple statements at once?
2020/05/31 15:35:01 routers/init.go:73:initDBEngine() [I] Backing off for 3 seconds
2020/05/31 15:35:04 routers/init.go:66:initDBEngine() [I] ORM engine initialization attempt #3/10...
2020/05/31 15:35:04 ...orm@v0.8.1/engine.go:351:Ping() [I] PING DATABASE mysql
2020/05/31 15:35:04 routers/init.go:72:initDBEngine() [E] ORM engine initialization attempt #3/10 failed. Error: commands out of sync. Did you run multiple statements at once?
2020/05/31 15:35:04 routers/init.go:73:initDBEngine() [I] Backing off for 3 seconds
2020/05/31 15:35:07 routers/init.go:66:initDBEngine() [I] ORM engine initialization attempt #4/10...
2020/05/31 15:35:07 ...orm@v0.8.1/engine.go:351:Ping() [I] PING DATABASE mysql
2020/05/31 15:35:07 routers/init.go:72:initDBEngine() [E] ORM engine initialization attempt #4/10 failed. Error: commands out of sync. Did you run multiple statements at once?
2020/05/31 15:35:07 routers/init.go:73:initDBEngine() [I] Backing off for 3 seconds
2020/05/31 15:35:10 routers/init.go:66:initDBEngine() [I] ORM engine initialization attempt #5/10...
2020/05/31 15:35:10 ...orm@v0.8.1/engine.go:351:Ping() [I] PING DATABASE mysql
2020/05/31 15:35:10 routers/init.go:72:initDBEngine() [E] ORM engine initialization attempt #5/10 failed. Error: commands out of sync. Did you run multiple statements at once?
2020/05/31 15:35:10 routers/init.go:73:initDBEngine() [I] Backing off for 3 seconds
2020/05/31 15:35:13 routers/init.go:66:initDBEngine() [I] ORM engine initialization attempt #6/10...
2020/05/31 15:35:13 ...orm@v0.8.1/engine.go:351:Ping() [I] PING DATABASE mysql
2020/05/31 15:35:13 routers/init.go:72:initDBEngine() [E] ORM engine initialization attempt #6/10 failed. Error: commands out of sync. Did you run multiple statements at once?
2020/05/31 15:35:13 routers/init.go:73:initDBEngine() [I] Backing off for 3 seconds
2020/05/31 15:35:16 routers/init.go:66:initDBEngine() [I] ORM engine initialization attempt #7/10...
2020/05/31 15:35:16 ...orm@v0.8.1/engine.go:351:Ping() [I] PING DATABASE mysql
2020/05/31 15:35:16 routers/init.go:72:initDBEngine() [E] ORM engine initialization attempt #7/10 failed. Error: commands out of sync. Did you run multiple statements at once?
2020/05/31 15:35:16 routers/init.go:73:initDBEngine() [I] Backing off for 3 seconds
2020/05/31 15:35:19 routers/init.go:66:initDBEngine() [I] ORM engine initialization attempt #8/10...
2020/05/31 15:35:19 ...orm@v0.8.1/engine.go:351:Ping() [I] PING DATABASE mysql
2020/05/31 15:35:19 routers/init.go:72:initDBEngine() [E] ORM engine initialization attempt #8/10 failed. Error: commands out of sync. Did you run multiple statements at once?
2020/05/31 15:35:19 routers/init.go:73:initDBEngine() [I] Backing off for 3 seconds
2020/05/31 15:35:22 routers/init.go:66:initDBEngine() [I] ORM engine initialization attempt #9/10...
2020/05/31 15:35:22 ...orm@v0.8.1/engine.go:351:Ping() [I] PING DATABASE mysql
2020/05/31 15:35:22 routers/init.go:72:initDBEngine() [E] ORM engine initialization attempt #9/10 failed. Error: commands out of sync. Did you run multiple statements at once?
2020/05/31 15:35:22 routers/init.go:73:initDBEngine() [I] Backing off for 3 seconds
2020/05/31 15:35:25 routers/init.go:66:initDBEngine() [I] ORM engine initialization attempt #10/10...
2020/05/31 15:35:25 ...orm@v0.8.1/engine.go:351:Ping() [I] PING DATABASE mysql
2020/05/31 15:35:25 routers/init.go:101:GlobalInit() [F] ORM engine initialization failed: commands out of sync. Did you run multiple statements at once?
2020/05/31 15:35:29 ...dules/setting/log.go:276:newLogService() [I] Gitea Log Mode: File(File:info)
2020/05/31 15:35:29 ...les/setting/cache.go:45:newCacheService() [I] Cache Service Enabled
2020/05/31 15:35:29 ...s/setting/session.go:44:newSessionService() [I] Session Service Enabled
2020/05/31 15:35:29 ...es/setting/mailer.go:106:newMailService() [I] Mail Service Enabled
2020/05/31 15:35:29 ...es/setting/mailer.go:117:newRegisterMailService() [I] Register Mail Service Enabled
2020/05/31 15:35:29 ...es/setting/mailer.go:128:newNotifyMailService() [I] Notify Mail Service Enabled
2020/05/31 15:35:29 routers/init.go:59:initDBEngine() [I] Beginning ORM engine initialization.
2020/05/31 15:35:29 routers/init.go:66:initDBEngine() [I] ORM engine initialization attempt #1/10...
2020/05/31 15:35:29 ...orm@v0.8.1/engine.go:351:Ping() [I] PING DATABASE mysql
2020/05/31 15:35:29 routers/init.go:72:initDBEngine() [E] ORM engine initialization attempt #1/10 failed. Error: commands out of sync. Did you run multiple statements at once?
2020/05/31 15:35:29 routers/init.go:73:initDBEngine() [I] Backing off for 3 seconds
2020/05/31 15:35:32 routers/init.go:66:initDBEngine() [I] ORM engine initialization attempt #2/10...
2020/05/31 15:35:32 ...orm@v0.8.1/engine.go:351:Ping() [I] PING DATABASE mysql
2020/05/31 15:35:32 routers/init.go:72:initDBEngine() [E] ORM engine initialization attempt #2/10 failed. Error: commands out of sync. Did you run multiple statements at once?
2020/05/31 15:35:32 routers/init.go:73:initDBEngine() [I] Backing off for 3 seconds
2020/05/31 15:35:35 routers/init.go:66:initDBEngine() [I] ORM engine initialization attempt #3/10...
2020/05/31 15:35:35 ...orm@v0.8.1/engine.go:351:Ping() [I] PING DATABASE mysql
2020/05/31 15:35:35 routers/init.go:72:initDBEngine() [E] ORM engine initialization attempt #3/10 failed. Error: commands out of sync. Did you run multiple statements at once?
2020/05/31 15:35:35 routers/init.go:73:initDBEngine() [I] Backing off for 3 seconds
2020/05/31 15:35:38 routers/init.go:66:initDBEngine() [I] ORM engine initialization attempt #4/10...
2020/05/31 15:35:38 ...orm@v0.8.1/engine.go:351:Ping() [I] PING DATABASE mysql
2020/05/31 15:35:38 routers/init.go:72:initDBEngine() [E] ORM engine initialization attempt #4/10 failed. Error: commands out of sync. Did you run multiple statements at once?
2020/05/31 15:35:38 routers/init.go:73:initDBEngine() [I] Backing off for 3 seconds
2020/05/31 15:35:41 routers/init.go:66:initDBEngine() [I] ORM engine initialization attempt #5/10...
2020/05/31 15:35:41 ...orm@v0.8.1/engine.go:351:Ping() [I] PING DATABASE mysql
2020/05/31 15:35:41 routers/init.go:72:initDBEngine() [E] ORM engine initialization attempt #5/10 failed. Error: commands out of sync. Did you run multiple statements at once?
2020/05/31 15:35:41 routers/init.go:73:initDBEngine() [I] Backing off for 3 seconds
2020/05/31 15:35:44 routers/init.go:66:initDBEngine() [I] ORM engine initialization attempt #6/10...
2020/05/31 15:35:44 ...orm@v0.8.1/engine.go:351:Ping() [I] PING DATABASE mysql
2020/05/31 15:35:44 routers/init.go:72:initDBEngine() [E] ORM engine initialization attempt #6/10 failed. Error: commands out of sync. Did you run multiple statements at once?
2020/05/31 15:35:44 routers/init.go:73:initDBEngine() [I] Backing off for 3 seconds
2020/05/31 15:35:47 routers/init.go:66:initDBEngine() [I] ORM engine initialization attempt #7/10...
2020/05/31 15:35:47 ...orm@v0.8.1/engine.go:351:Ping() [I] PING DATABASE mysql
2020/05/31 15:35:47 routers/init.go:72:initDBEngine() [E] ORM engine initialization attempt #7/10 failed. Error: commands out of sync. Did you run multiple statements at once?
2020/05/31 15:35:47 routers/init.go:73:initDBEngine() [I] Backing off for 3 seconds
2020/05/31 15:35:50 routers/init.go:66:initDBEngine() [I] ORM engine initialization attempt #8/10...
2020/05/31 15:35:50 ...orm@v0.8.1/engine.go:351:Ping() [I] PING DATABASE mysql
2020/05/31 15:35:50 routers/init.go:72:initDBEngine() [E] ORM engine initialization attempt #8/10 failed. Error: commands out of sync. Did you run multiple statements at once?
2020/05/31 15:35:50 routers/init.go:73:initDBEngine() [I] Backing off for 3 seconds
2020/05/31 15:35:53 routers/init.go:66:initDBEngine() [I] ORM engine initialization attempt #9/10...
2020/05/31 15:35:53 ...orm@v0.8.1/engine.go:351:Ping() [I] PING DATABASE mysql
2020/05/31 15:35:53 routers/init.go:72:initDBEngine() [E] ORM engine initialization attempt #9/10 failed. Error: commands out of sync. Did you run multiple statements at once?
2020/05/31 15:35:53 routers/init.go:73:initDBEngine() [I] Backing off for 3 seconds
2020/05/31 15:35:56 routers/init.go:66:initDBEngine() [I] ORM engine initialization attempt #10/10...
2020/05/31 15:35:56 ...orm@v0.8.1/engine.go:351:Ping() [I] PING DATABASE mysql
2020/05/31 15:35:56 routers/init.go:101:GlobalInit() [F] ORM engine initialization failed: commands out of sync. Did you run multiple statements at once?
2020/05/31 15:36:00 ...dules/setting/log.go:276:newLogService() [I] Gitea Log Mode: File(File:info)
2020/05/31 15:36:00 ...les/setting/cache.go:45:newCacheService() [I] Cache Service Enabled
2020/05/31 15:36:00 ...s/setting/session.go:44:newSessionService() [I] Session Service Enabled
2020/05/31 15:36:00 ...es/setting/mailer.go:106:newMailService() [I] Mail Service Enabled
2020/05/31 15:36:00 ...es/setting/mailer.go:117:newRegisterMailService() [I] Register Mail Service Enabled
2020/05/31 15:36:00 ...es/setting/mailer.go:128:newNotifyMailService() [I] Notify Mail Service Enabled
2020/05/31 15:36:00 routers/init.go:59:initDBEngine() [I] Beginning ORM engine initialization.
2020/05/31 15:36:00 routers/init.go:66:initDBEngine() [I] ORM engine initialization attempt #1/10...
2020/05/31 15:36:00 ...orm@v0.8.1/engine.go:351:Ping() [I] PING DATABASE mysql
2020/05/31 15:36:00 routers/init.go:72:initDBEngine() [E] ORM engine initialization attempt #1/10 failed. Error: commands out of sync. Did you run multiple statements at once?
2020/05/31 15:36:00 routers/init.go:73:initDBEngine() [I] Backing off for 3 seconds
2020/05/31 15:36:01 ...eful/manager_unix.go:133:handleSignals() [W] PID 885. Received SIGTERM. Shutting down...
2020/05/31 15:36:01 .../graceful/manager.go:184:doHammerTime() [W] Setting Hammer condition
2020/05/31 15:36:02 .../graceful/manager.go:198:doTerminate() [W] Terminating
2020/05/31 15:36:03 routers/init.go:101:GlobalInit() [F] ORM engine initialization failed: Aborted due to shutdown:
	in retry ORM engine initialization
@techknowlogick
Copy link
Member

Looking at your logs it looks like the only SQL statement that is run is PING DATABASE mysql and that is what it is failing on. Are you able to run this query directly against your database?

@AlphaJack
Copy link
Author

Do you mean running it in MariaDB shell? I get the following error:

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| gitea-db           |
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
8 rows in set (2.531 sec)


MariaDB [(none)]> PING DATABASE mysql;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'PING DATABASE mysql' at line 1

If I remove the install lock and try to setup the database from the web gui I get the error I encountered the first time I installed Gitea:

The database settings are invalid: commands out of sync. Did you run multiple statements at once?

@AlphaJack
Copy link
Author

Tried #9279, I can use MySQL if I set the sock binding
in /etc/my.cnf:

[mysqld]
socket = /var/run/mysqld/mysqld.sock

in /etc/gitea/app.ini:

HOST                = /var/run/mysqld/mysqld.sock
;HOST                = 127.0.0.1:3306

Why?

@AlphaJack AlphaJack changed the title Can't start Gitea after migrating the database (SQLite -> mySQL) Can't start Gitea after migrating the database (SQLite -> MySQL) Jun 11, 2020
@zeripath
Copy link
Contributor

zeripath commented Jun 11, 2020

I suspect you need to set:

[database]
NAME=gitea-db
...

in your app.ini

@AlphaJack AlphaJack changed the title Can't start Gitea after migrating the database (SQLite -> MySQL) Can't connect to MySQL via localhost, I need to use a socket Jun 13, 2020
@stale
Copy link

stale bot commented Aug 13, 2020

This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.

@stale stale bot added the issue/stale label Aug 13, 2020
@AlphaJack AlphaJack changed the title Can't connect to MySQL via localhost, I need to use a socket Can't connect to MySQL via TCP, I need to use UNIX socket Aug 13, 2020
@zeripath
Copy link
Contributor

I suspect the issue is the lack of permission to connect over TCP. I note that you said you ran:

GRANT ALL ON gitea-db.* TO 'gitea'@'localhost' IDENTIFIED BY 'XXXXXX' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;

This does not necessarily give access to tcp connection over 127.0.0.1

See https://stackoverflow.com/questions/19712307/mysql-localhost-127-0-0-1

I suggest you try:

GRANT ALL ON gitea-db.* TO 'gitea'@127.0.0.1 IDENTIFIED BY 'XXXXXX' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;

I appreciate thatmysql -u gitea -p gitea-db may work but that is connecting to mysql over its unix socket you would need to use mysql --protocol=TCP -u gitea -p gitea-db to force mysql's client to go over TCP.

@stale stale bot removed the issue/stale label Aug 13, 2020
@AlphaJack
Copy link
Author

mysql --protocol=TCP -u gitea -p gitea-db returns

ERROR 1130 (HY000): Host '127.0.0.1' is not allowed to connect to this MariaDB server

I noticed the same error for other users.

This answer from the link you posted helped me, I had skip-name-resolve = 1 in /etc/my.cnf

Thank you

@zeripath zeripath added the issue/not-a-bug The reported issue is the intended behavior or the problem is not inside Gitea label Aug 14, 2020
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue/not-a-bug The reported issue is the intended behavior or the problem is not inside Gitea
Projects
None yet
Development

No branches or pull requests

3 participants