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

v4 regression? Getting "no database name" with MySQL 8 #139

Closed
fsouza opened this issue Dec 18, 2018 · 3 comments
Closed

v4 regression? Getting "no database name" with MySQL 8 #139

fsouza opened this issue Dec 18, 2018 · 3 comments

Comments

@fsouza
Copy link
Contributor

fsouza commented Dec 18, 2018

Describe the Bug

Whenever trying to use v4 and MySQL 8, I get the "error: no database name". The error doesn't happen if I use the binary obtained by running go get -tags mysql github.com/golang-migrate/migrate/cmd/migrate or if I downgrade to MySQL 5.

Steps to Reproduce

Programmatically:

$ mkdir /tmp/debug
$ cd /tmp/debug
$ go mod init github.com/fsouza/debug
$ cat > debug.go
package main

import (
	"os"

	"github.com/golang-migrate/migrate/v4"
	_ "github.com/golang-migrate/migrate/v4/database/mysql"
	_ "github.com/golang-migrate/migrate/v4/source/file"
)

func main() {
	const connString = "mysql://root:@tcp(127.0.0.1:3306)/whatever"

	_, err := migrate.New("file://"+os.Args[1], connString)
	if err != nil {
		panic(err)
	}
}
^-D
$ go build
$ ./debug <path to migrations>
panic: no database name

goroutine 1 [running]:
main.main()
	/tmp/debug/debug.go:16 +0xc4

Expected Behavior

Migrations should run.

Migrate Version

$ cat go.mod
module github.com/fsouza/debug

go 1.12

require github.com/golang-migrate/migrate/v4 v4.1.0

Loaded Source Drivers

file (see debug.go above)

Loaded Database Drivers

mysql (see debug.go above)

Go Version

$ go version
go version devel +99e4ddd053 Tue Dec 18 00:13:58 2018 +0000 darwin/amd64

No difference with Go 1.11.4.

@dhui
Copy link
Member

dhui commented Dec 18, 2018

My guess is that there's an issue w/ your DSN. e.g. use root@ instead if root:@.

Have you tried connecting using the mysql driver directly w/o migrate?

@fsouza
Copy link
Contributor Author

fsouza commented Dec 18, 2018

@dhui go-sql-driver works fine with that :, but I removed it just in case and the behavior is still the same (also, migrate splits and reconstructs the DSN). Authentication is fine, migrate fails when it tries to run the command SELECT DATABASE().

But yeah, I dug a little bit and it is a bug with go-sql-driver. Good news is that the bug is already fixed on v1.4.1, so here's a PR: #141

@dhui
Copy link
Member

dhui commented Dec 18, 2018

@fsouza Thanks for investigating and opening a PR to fix!

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

No branches or pull requests

2 participants