dumpling
dumpling copied to clipboard
unix_socket support
Mariadb supports Unix Socket Authentication Plugin - https://mariadb.com/kb/en/authentication-plugin-unix-socket/ With it it is possible to login without password, for example:
[root@localhost ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 5672
Server version: 10.4.19-MariaDB-log MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
dumpling seems to not support it:
[root@localhost ~]# ./dumpling -P3306
Release version:
Git commit hash:
Git branch:
Build timestamp: 2021-06-14 04:26:05Z
Go version: go version go1.16.5 linux/amd64
[2021/06/21 15:55:51.754 +00:00] [INFO] [versions.go:55] ["Welcome to dumpling"] ["Release Version"=] ["Git Commit Hash"=] ["Git Branch"=] ["Build timestamp"="2021-06-14 04:26:05"] ["Go Version"="go version go1.16.5 linux/amd64"]
create dumper failed: sql: SELECT version(): Error 1045: Access denied for user 'root'@'127.0.0.1' (using password: NO)
[root@localhost ~]# ./dumpling -hlocalhost -P3306
Release version:
Git commit hash:
Git branch:
Build timestamp: 2021-06-14 04:26:05Z
Go version: go version go1.16.5 linux/amd64
[2021/06/21 15:56:05.093 +00:00] [INFO] [versions.go:55] ["Welcome to dumpling"] ["Release Version"=] ["Git Commit Hash"=] ["Git Branch"=] ["Build timestamp"="2021-06-14 04:26:05"] ["Go Version"="go version go1.16.5 linux/amd64"]
create dumper failed: sql: SELECT version(): Error 1045: Access denied for user 'root'@'::1' (using password: NO)
It would be nice to support it.
We will check this later.
I "fixed" it by using the following:
diff --git a/v4/export/config.go b/v4/export/config.go
index b7bf104..a46168c 100644
--- a/v4/export/config.go
+++ b/v4/export/config.go
@@ -182,8 +182,8 @@ func (conf *Config) String() string {
func (conf *Config) GetDSN(db string) string {
// maxAllowedPacket=0 can be used to automatically fetch the max_allowed_packet variable from server on every connection.
// https://github.com/go-sql-driver/mysql#maxallowedpacket
- dsn := fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?collation=utf8mb4_general_ci&readTimeout=%s&writeTimeout=30s&interpolateParams=true&maxAllowedPacket=0",
- conf.User, conf.Password, conf.Host, conf.Port, db, conf.ReadTimeout)
+ dsn := fmt.Sprintf("%s:%s@unix(/var/lib/mysql/mysql.sock)/%s?collation=utf8mb4_general_ci&readTimeout=%s&writeTimeout=30s&interpolateParams=true&maxAllowedPacket=0",
+ conf.User, conf.Password, db, conf.ReadTimeout)
if len(conf.Security.CAPath) > 0 {
dsn += "&tls=dumpling-tls-target"
}
I think this should be labeled as "good first issue" as this probably just needs:
- An additional flag for specifying the socket (e.g.
--socket) - Updating the DSN based on this (as described above)
- Adding some tests. For this is should be possible to test against a TiDB instance that is configured with a socket (
./tib-server -socket ...) - Updating docs if needed.
- Maybe checking for invalid flag combinations, like specifying a port and a socket.