ory / kratos

The most scalable and customizable identity server on the market. Replace your Homegrown, Auth0, Okta, Firebase with better UX and DX. Has all the tablestakes: Passkeys, Social Sign In, Multi-Factor Auth, SMS, SAML, TOTP, and more. Written in Go, cloud native, headless, API-first. Available as a service on Ory Network and for self-hosters.
https://www.ory.sh/?utm_source=github&utm_medium=banner&utm_campaign=kratos
Apache License 2.0
11.24k stars 963 forks source link

mysql Unable to determine network #2618

Closed zhanghepeng closed 2 years ago

zhanghepeng commented 2 years ago

Preflight checklist

Describe the bug

mysql> create user dev@'%' identified by 'nzJ9Ftj5i15FXQV';
Query OK, 0 rows affected (0.01 sec)

mysql> grant all privileges on kratos.* to dev@'%';
Query OK, 0 rows affected (0.01 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye
root@VM-0-8-debian:/data/soft/kratos/conf# mysql -udev -pnzJ9Ftj5i15FXQV
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 166
Server version: 8.0.29 MySQL Community Server - GPL

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> exit
Bye
root@VM-0-8-debian:/data/soft/kratos/conf# echo $DSN
mysql://dev:nzJ9Ftj5i15FXQV@tcp(127.0.0.1:3306)/kratos?max_conns=2
root@VM-0-8-debian:/data/soft/kratos/conf# 
root@VM-0-8-debian:/data/soft/kratos/conf# kratos serve -c kratos.yml 
INFO[2022-07-26T17:13:12+08:00] No tracer configured - skipping tracing setup  audience=application service_name=Ory Kratos service_version=v0.10.1
DEBU[2022-07-26T17:13:12+08:00] Connecting to SQL Database                    audience=application connMaxLifetime=0s idlePool=1 pool=2 service_name=Ory Kratos service_version=v0.10.1
WARN[2022-07-26T17:13:12+08:00] Unable to determine network, retrying.        audience=application error=map[debug: message:Unable to locate the table reason: stack_trace:
github.com/ory/x/sqlcon.HandleError
        /go/pkg/mod/github.com/ory/x@v0.0.392/sqlcon/error.go:85
github.com/ory/x/networkx.(*Manager).Determine
        /go/pkg/mod/github.com/ory/x@v0.0.392/networkx/manager.go:42
github.com/ory/kratos/persistence/sql.(*Persister).DetermineNetwork
        /project/persistence/sql/persister.go:80
github.com/ory/kratos/driver.(*RegistryDefault).Init.func1
        /project/driver/registry_default.go:590
github.com/cenkalti/backoff.RetryNotify
        /go/pkg/mod/github.com/cenkalti/backoff@v2.2.1+incompatible/retry.go:37
github.com/cenkalti/backoff.Retry
        /go/pkg/mod/github.com/cenkalti/backoff@v2.2.1+incompatible/retry.go:24
github.com/ory/kratos/driver.(*RegistryDefault).Init
        /project/driver/registry_default.go:531
github.com/ory/kratos/driver.New
        /project/driver/factory.go:15
github.com/ory/kratos/cmd/serve.NewServeCmd.func1
        /project/cmd/serve/root.go:33
github.com/spf13/cobra.(*Command).execute
        /go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:860
github.com/spf13/cobra.(*Command).ExecuteC
        /go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:974
github.com/spf13/cobra.(*Command).Execute
        /go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:902
github.com/ory/kratos/cmd.Execute
        /project/cmd/root.go:51
main.main
        /project/main.go:35
runtime.main
        /usr/local/go/src/runtime/proc.go:255
runtime.goexit
        /usr/local/go/src/runtime/asm_amd64.s:1581 status:Internal Server Error status_code:500] service_name=Ory Kratos service_version=v0.10.1
DEBU[2022-07-26T17:13:12+08:00] Connecting to SQL Database                    audience=application connMaxLifetime=0s idlePool=1 pool=2 service_name=Ory Kratos service_version=v0.10.1
WARN[2022-07-26T17:13:13+08:00] Unable to determine network, retrying.        audience=application error=map[debug: message:Unable to locate the table reason: stack_trace:
github.com/ory/x/sqlcon.HandleError
        /go/pkg/mod/github.com/ory/x@v0.0.392/sqlcon/error.go:85
github.com/ory/x/networkx.(*Manager).Determine
        /go/pkg/mod/github.com/ory/x@v0.0.392/networkx/manager.go:42
github.com/ory/kratos/persistence/sql.(*Persister).DetermineNetwork
        /project/persistence/sql/persister.go:80
github.com/ory/kratos/driver.(*RegistryDefault).Init.func1
        /project/driver/registry_default.go:590
github.com/cenkalti/backoff.RetryNotify
        /go/pkg/mod/github.com/cenkalti/backoff@v2.2.1+incompatible/retry.go:37
github.com/cenkalti/backoff.Retry
        /go/pkg/mod/github.com/cenkalti/backoff@v2.2.1+incompatible/retry.go:24
github.com/ory/kratos/driver.(*RegistryDefault).Init
        /project/driver/registry_default.go:531
github.com/ory/kratos/driver.New
        /project/driver/factory.go:15
github.com/ory/kratos/cmd/serve.NewServeCmd.func1
        /project/cmd/serve/root.go:33
github.com/spf13/cobra.(*Command).execute
        /go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:860
github.com/spf13/cobra.(*Command).ExecuteC
        /go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:974
github.com/spf13/cobra.(*Command).Execute
        /go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:902
github.com/ory/kratos/cmd.Execute
        /project/cmd/root.go:51
main.main
        /project/main.go:35
runtime.main
        /usr/local/go/src/runtime/proc.go:255
runtime.goexit
        /usr/local/go/src/runtime/asm_amd64.s:1581 status:Internal Server Error status_code:500] service_name=Ory Kratos service_version=v0.10.1

why, i can't connect to mysql database?

Reproducing the bug

1.create mysql user success. 2.use the user with mysql client can connect to database.

  1. but, can't connect to database.

Relevant log output

No response

Relevant configuration

No response

Version

v0.10.1

On which operating system are you observing this issue?

Linux

In which environment are you deploying?

Binary

Additional Context

No response

aeneasr commented 2 years ago

You need to run hydra migrate sql first

zhanghepeng commented 2 years ago

thankyou.