Skip to content
This repository has been archived by the owner on Aug 21, 2023. It is now read-only.

unix_socket support #299

Open
nerijus opened this issue Jun 21, 2021 · 3 comments
Open

unix_socket support #299

nerijus opened this issue Jun 21, 2021 · 3 comments

Comments

@nerijus
Copy link

nerijus commented Jun 21, 2021

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.

@lichunzhu
Copy link
Contributor

We will check this later.

@nerijus
Copy link
Author

nerijus commented Jun 23, 2021

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"
        }

@dveeden
Copy link
Contributor

dveeden commented Jul 23, 2021

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants