diff --git a/conventional.yaml b/conventional.yaml index d39b3195..bf587af7 100644 --- a/conventional.yaml +++ b/conventional.yaml @@ -663,8 +663,9 @@ datastore: mysql: enabled: false host: "localhost" - # port is unnecessary for connections via unix domain socket: - #port: 3306 + port: 3306 + # if socket-path is set, it will be used instead of host:port + #socket-path: "/var/run/mysqld/mysqld.sock" user: "oragono" password: "hunter2" history-database: "oragono_history" diff --git a/irc/mysql/config.go b/irc/mysql/config.go index c4a19ae5..2c4ff54c 100644 --- a/irc/mysql/config.go +++ b/irc/mysql/config.go @@ -12,6 +12,7 @@ type Config struct { Enabled bool Host string Port int + SocketPath string `yaml:"socket-path"` User string Password string HistoryDatabase string `yaml:"history-database"` diff --git a/irc/mysql/history.go b/irc/mysql/history.go index b1b86a23..5a6cb000 100644 --- a/irc/mysql/history.go +++ b/irc/mysql/history.go @@ -88,7 +88,9 @@ func (mysql *MySQL) getExpireTime() (expireTime time.Duration) { func (m *MySQL) Open() (err error) { var address string - if m.config.Port != 0 { + if m.config.SocketPath != "" { + address = fmt.Sprintf("unix(%s)", m.config.SocketPath) + } else if m.config.Port != 0 { address = fmt.Sprintf("tcp(%s:%d)", m.config.Host, m.config.Port) } diff --git a/oragono.yaml b/oragono.yaml index 90e43920..dfb799b4 100644 --- a/oragono.yaml +++ b/oragono.yaml @@ -684,8 +684,9 @@ datastore: mysql: enabled: false host: "localhost" - # port is unnecessary for connections via unix domain socket: - #port: 3306 + port: 3306 + # if socket-path is set, it will be used instead of host:port + #socket-path: "/var/run/mysqld/mysqld.sock" user: "oragono" password: "hunter2" history-database: "oragono_history"