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

Enable native authentication in MySQL #6628

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions receiver/mysqlreceiver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ The following settings are optional:
- `endpoint`: (default = `localhost:3306`)
- `username`: (default = `root`)
- `password`: The password to the username.
- `allow_native_passwords`: (default = `true`)
- `database`: The database name. If not specified, metrics will be collected for all databases.

- `collection_interval` (default = `10s`): This receiver collects metrics on an interval. This value must be a string readable by Golang's [time.ParseDuration](https://pkg.go.dev/time#ParseDuration). Valid time units are `ns`, `us` (or `µs`), `ms`, `s`, `m`, `h`.
Expand Down
11 changes: 6 additions & 5 deletions receiver/mysqlreceiver/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ var _ client = (*mySQLClient)(nil)

func newMySQLClient(conf *Config) client {
driverConf := mysql.Config{
User: conf.Username,
Passwd: conf.Password,
Net: conf.Transport,
Addr: conf.Endpoint,
DBName: conf.Database,
User: conf.Username,
Passwd: conf.Password,
Net: conf.Transport,
Addr: conf.Endpoint,
DBName: conf.Database,
AllowNativePasswords: conf.AllowNativePasswords,
}
connStr := driverConf.FormatDSN()

Expand Down
1 change: 1 addition & 0 deletions receiver/mysqlreceiver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ type Config struct {
Username string `mapstructure:"username,omitempty"`
Password string `mapstructure:"password,omitempty"`
Database string `mapstructure:"database,omitempty"`
AllowNativePasswords bool `mapstructure:"allow_native_passwords,omitempty"`
confignet.NetAddr `mapstructure:",squash"`
}
3 changes: 2 additions & 1 deletion receiver/mysqlreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ func createDefaultConfig() config.Receiver {
ReceiverSettings: config.NewReceiverSettings(config.NewComponentID(typeStr)),
CollectionInterval: 10 * time.Second,
},
Username: "root",
AllowNativePasswords: true,
Username: "root",
NetAddr: confignet.NetAddr{
Endpoint: "localhost:3306",
Transport: "tcp",
Expand Down