๋ฌด์จ ์ผ์ด ์ผ์ด๋์ผํ๋์ง, ๋์ ๋ฌด์จ ์ผ์ด ์ผ์ด๋๋์ง ์๋ ค์ฃผ์ธ์.
mysql5.7 ์ ์์๋ ์ธ์ฆ ํ๋ฌ๊ทธ์ธ
// version go1.10.2 darwin/amd64
db, err := sql.Open("mysql", "admin:admin@tcp(127.0.0.1:9696)/test")
if err != nil {
fmt.Println("failed to open database:", err.Error())
return
}
defer db.Close()
rows, err := db.Query("SELECT id,str FROM test_shard_hash")
if err != nil {
fmt.Println("fetech data failed:", err.Error())
return
}
defer rows.Close()
for rows.Next() {
var id int
var str string
rows.Scan(&id, &str)
fmt.Println("uid:", id, "name:", str)
}
[mysql] 2018/06/06 22:15:07 auth.go:293: unknown auth plugin:
[mysql] 2018/06/06 22:15:07 driver.go:120: could not use requested auth plugin '': this authentication plugin is not supported
๋๋ผ์ด๋ฒ ๋ฒ์ (๋๋ git SHA) : origin / master
Go ๋ฒ์ : go1.10.2 darwin / amd64
์๋ฒ ๋ฒ์ : MySQL 5.7
์๋ฒ OS : macOS 10.13.4 (17E202)
๋ค์ ์น์ ๋ ๋ฌธ์ ํ ํ๋ฆฟ์์ ์ข์ ์ด์ ์ ๋๋ค.
### Configuration
*Driver version (or git SHA):*
*Go version:* run `go version` in your console
*Server version:* E.g. MySQL 5.6, MariaDB 10.0.20
*Server OS:* E.g. Debian 8.1 (Jessie), Windows 10
๋ด ์๊ฐ์๋ ๋ง์คํฐ ๋ธ๋์น๊ฐ ์ต์ ๋ฒ์ ์ด ์๋๋ผ๋ ๊ฒ์
๋๋ค. git rev-parse HEAD
ํน์ ๋ฒ์ ์ ํ์ธํ๊ณ ํ์ํ ๊ฒฝ์ฐ ์ต์ ๋ฒ์ ์ผ๋ก ๋ค์ ์๋ํ์ญ์์ค.
์๋ ํ์ธ์, ์ ๋์ด ๋ฌธ์ ๊ฐ ์์ต๋๋ค. ๋น์ ์ ๊ฒฐ์ฌ ํ์ต๋๊น?
์๋
์ด ๋ถ๊ธฐ๊ฐ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํฉ๋๊น? https://github.com/go-sql-driver/mysql/tree/empty_auth
์ด์จ๋ ์ด ๋ธ๋ก https://github.com/go-sql-driver/mysql/blob/d523deb1b23d913de5bdada721a6071e71283618/packets.go#L157 -L167 ๋ค์ ๊ฐ๋จํ print(data)
์ฝ์
ํ ์ ์๋ค๋ฉด ์ข์ ๊ฒ์
๋๋ค. ๊ทธ๋ฆฌ๊ณ ์ฌ๊ธฐ https://github.com/go-sql-driver/mysql/blob/d523deb1b23d913de5bdada721a6071e71283618/packets.go#L469 -L474 ๊ฒฐ๊ณผ ํจํท ๋คํ๋ฅผ ๋ณด๋ด์ ํ๊ท ํ
์คํธ๋ฅผ ๋ง๋๋ ๋ฐ ์ฌ์ฉํ ์ ์์ต๋๋ค.
@gocuntian ๋ฌธ์ ๋ฅผ ํด๊ฒฐ ํ์ต๋๊น?
๋๋ ๊ฐ์ ์ง๋ฌธ์ด ์๋๋ฐ, ๋ด ์ง๋ฌธ์ ๋ด ์๋ฒ๊ฐ ์ธ์ฆ ๋ฐฉ๋ฒ์์ด ์ด๊ธฐํ ํจํท์ ๋ณด๋ด๋ ๊ฒ์
๋๋ค.
accroding ์์ค ์ฝ๋ :
auth.go : 240, func auth ()์ ๋ค์ ์ฝ๋๋ฅผ ์ถ๊ฐํฉ๋๋ค.
if plugin == ""{
ํ๋ฌ๊ทธ์ธ = "mysql_native_password"
}
๋ด ๋ฌธ์ ๊ฐ ํด๊ฒฐ๋์์ต๋๋ค
MySQL 5.1์ ์ฐ๊ฒฐํ ๋ ๋์ผํ ๊ฒฝ๊ณ ๊ฐ ํ์๋ฉ๋๋ค.
auth.go:293: unknown auth plugin:
driver.go:120: could not use requested auth plugin '': this authentication plugin is not supported
https://github.com/go-sql-driver/mysql/tree/empty_auth ์ง์ ์์ ์์ ํ์ต๋๋ค. ์ง์ ์ ๋ณํฉ ํ ๊ณํ์ด ์์ต๋๊น? ์๋ ํ์ธ์.
๋๋ ๊ฐ์ ๋ฌธ์ ๋ฅผ ๊ฐ์ง๊ณ ์๋ค.
driver.go:113: could not use requested auth plugin 'mysql_native_password': this user requires mysql native password authentication.
๋ง์คํฐ์์ ์คํจ (๊ฐ์ ธ ์ค๊ธฐ)
v1.4.0์์ ์คํจ
v1.3.0์์ ์๋
ํ์ํ ๊ฒฝ์ฐ ๋ ๋ง์ ์ ๋ณด๋ฅผ ์ ๊ณต ํ ์ ์์ต๋๋ค. ์๋๋ฉด ๊ทธ๊ฒ์ด ๋ ๋ค๋ฅธ ๋ฌธ์ ๋ผ๊ณ ์๊ฐํ๊ณ ์๋ก์ด ๋ฌธ์ ๋ฅผ ๋ง๋ค์ด์ผํฉ๋๊น?
๋ค์ ์ด์์ต๋๋ค. # 828 ๋ฐ # 835 ์ฐธ์กฐ ( empty_auth
์ง์ ์ PR)
์ฌ๊ธฐ์ ๋งค์ฐ ์ ์ฌํ ์ฆ์์ ๊ฐ์ง ๋ ๊ฐ์ง ๋ฌธ์ ๊ฐ์๋ ๊ฒ ๊ฐ์ต๋๋ค.
# 835์ ์์ ์ ๋น ์ธ์ฆ ํ๋ฌ๊ทธ์ธ ์ด๋ฆ์ด์๋ ๊ฒฝ์ฐ๋ฅผ ์์ ํ๋ ๊ฒ์ผ๋ก ๋ณด์ด์ง๋ง @mbertschler ๋ฐ mysql_native_password
ํ๋ฌ๊ทธ์ธ์์ ๋ฐ์ํ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ์ง ๋ชปํฉ๋๋ค (https://github.com/ ์ฐธ์กฐ). ์์ธํ ๋ด์ฉ์ go-sql-driver / mysql / issues / 828 # issuecomment-401856689๋ฅผ ์ฐธ์กฐํ์ธ์.
๋ค๋ฅธ ๋ฌธ์ ์ผ ์๋ ์์ง๋ง # 835์์ ์ ์ํ ๊ฒ๋ณด๋ค ๋ ๊ด๋ฒ์ํ ์์ ์ด ํ์ํ๋ค๊ณ ์๊ฐํฉ๋๋ค.
@ kwoodhouse93 ์ฌ๊ธฐ์ ์ค๋ช
๋๋๋ก ์ฐ๋ฆฌ์๊ฒ ์๋ฅผ ๋ค์ด, ํจํท ๋ก๊ทธ๋ฅผ ๋ณด๋ผ ์ : https://github.com/go-sql-driver/mysql/issues/815#issuecomment ๋ฐ๋์งํ๊ฒ ์ฌ์ฉ (-396244978๋ฅผ empty_auth
์ง์ / # 835)?
๋ํ &allowNativaPasswords=true
๋ฅผ DSN์ ์ถ๊ฐํด๋ณด์ญ์์ค (๊ธฐ๋ณธ์ ์ผ๋ก true
์ด์ด์ผ ํจ).
empty_auth
๋ธ๋์น๋ฅผ ์ฌ์ฉํ์ฌ ์ธ๊ธ ๋ ์์น์ print(data)
๋ฅผ ์ถ๊ฐํ์ผ๋ฉฐ ๊ฒฐ๊ณผ๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
[74/4092]0xc42036c004[mysql] 2018/07/13 11:49:18 driver.go:123: could not use requested auth plugin 'mysql_native_password': this user requires mysql native password authentication.
[74/4092]0xc420371004[mysql] 2018/07/13 11:49:26 driver.go:123: could not use requested auth plugin 'mysql_native_password': this user requires mysql native password authentication.
...
์ฌ ์๋๋ฅผ ์ค์งํ๊ธฐ ์ ์ 12 ๋ฒ ๋ฐ๋ณต๋์์ผ๋ฉฐ ๊ฐ ์ฃผ์๋ ์ฝ๊ฐ ์ฉ ๋ค๋ฆ ๋๋ค.
๋ด DSN๊ณผ ๊ด๋ จํ์ฌ mysql.Config
์ ํจ๊ป FormatDSN()
์์ต๋๋ค. AllowNativePasswords
๋ Config
๊ตฌ์กฐ์ฒด๋ฅผ ๋ง๋ค ๋ ์๋ต๋์์ผ๋ฏ๋ก AllowNativePasswords: true,
. ์ด๋ก ์ธํด ๋์์ด ๋ค์ ๋ณ๊ฒฝ๋์์ง๋ง ๊ถ๊ทน์ ์ผ๋ก ๋์ผํ ์ค๋ฅ๊ฐ ๋ฐํ๋์์ต๋๋ค.
[74/4092]0xc420294004[7/4092]0xc420294004S[74/4092]0xc4201bb004[mysql] 2018/07/13 11:53:13 driver.go:123: could not use requested auth plugin 'mysql_native_password': this user requires mysql native password authentication.
(์ฐธ๊ณ , ์ด๋ฒ์๋ ๋ฐ๋ณต๋์ง ์์์ต๋๋ค. ํ ๋ฒ ์คํจํ๊ณ ํด๋ผ์ด์ธํธ ์ฑ์ ์ค๋ฅ๋ฅผ ๋ฐํํ์ต๋๋ค.)
print(data)
์ํด ์์ฑ ๋ ์ถ๋ ฅ์ ๋ณด๋ฉด ํด๋น ์ฃผ์์ ๋ด์ฉ์๋ณด๊ณ ์ถ์ต๋๊น? ๋ฐฉ๋ฒ์ ์๋ ค ์ฃผ์๋ฉด ๋ค์ ์๋ํด ์ฃผ์๋ฉด ๊ธฐ์ฉ๋๋ค (๋ ์์ ์ ๋ณด ๊ฒ ์ง๋ง ์ค๋์ ์ด๊ฒ์ ๋ ๋ง์ ์๊ฐ์ ํ ์ ํ ์๊ฐ์ด ์์ต๋๋ค).
์ ๊ทธ๋ ์ด๋ํ๊ณ ์ด ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค.
could not use requested auth plugin 'mysql_native_password': this user requires mysql native password authentication.
github.com/GoogleCloudPlatform/cloudsql-proxy/proxy/dialers/mysql์ DialCfg์ ํจ๊ป ํ๋ก์ ๋ค์ด์ผ๋ฌ๋ฅผ ์ฌ์ฉํ๊ณ ์์ผ๋ฉฐ, ์ ๊ฒฝ์ฐ ๊ฐ๋จํ ์์ ์ ๊ตฌ์ฑ ๊ตฌ์กฐ์ฒด์ AllowNativePasswords๋ฅผ ์ถ๊ฐํ๋ ๊ฒ์ ๋๋ค.
&mysqldriver.Config{
AllowNativePasswords: true,
...
}
@mglonnro ์ฐธ์กฐ https://github.com/go-sql-driver/mysql/issues/815#issuecomment -425704501
์ด ์ค๋ฅ๋ ๊ตฌ์ฑ์์ AllowNativePasswords: true
๋ฅผ ์ง์ ํ์ฌ ์ ๊ฒฝ์ฐ์ ํด๊ฒฐ๋์์ต๋๋ค.
AllowNativePassword๋ ๊ธฐ๋ณธ์ ์ผ๋ก true์
๋๋ค.
Config{}
๋ฅผ ์ฌ์ฉํ์ฌ ๊ตฌ์ฑ ๊ฐ์ฒด๋ฅผ ๋ง๋ค๋ฉด ์๋ฉ๋๋ค. DSN ๋๋ NewConfig()
ํฉ๋๋ค.
https://godoc.org/github.com/go-sql-driver/mysql#Config
DSN ๋ฌธ์์ด์์ ๊ตฌ๋ฌธ ๋ถ์๋๋ ๋์ ์ ๊ตฌ์ฑ์ด ์์ฑ๋๋ ๊ฒฝ์ฐ ๊ธฐ๋ณธ๊ฐ์ ์ค์ ํ๋ NewConfig ํจ์๋ฅผ ์ฌ์ฉํด์ผํฉ๋๋ค.
๊ฐ์ฌ. API ๋ฌธ์๋ฅผ ์ฝ๊ณ ํด๋น ๋จ๊ณ๋ฅผ ๋ ์ณค๊ธฐ ๋๋ฌธ์ Config
๋ง๋ค์์ต๋๋ค.
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
์ ๊ทธ๋ ์ด๋ํ๊ณ ์ด ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค.
could not use requested auth plugin 'mysql_native_password': this user requires mysql native password authentication.
github.com/GoogleCloudPlatform/cloudsql-proxy/proxy/dialers/mysql์ DialCfg์ ํจ๊ป ํ๋ก์ ๋ค์ด์ผ๋ฌ๋ฅผ ์ฌ์ฉํ๊ณ ์์ผ๋ฉฐ, ์ ๊ฒฝ์ฐ ๊ฐ๋จํ ์์ ์ ๊ตฌ์ฑ ๊ตฌ์กฐ์ฒด์ AllowNativePasswords๋ฅผ ์ถ๊ฐํ๋ ๊ฒ์ ๋๋ค.
&mysqldriver.Config{ AllowNativePasswords: true, ... }