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

how to set charset utf8 #124

Open
gunsluo opened this issue Jan 26, 2016 · 4 comments
Open

how to set charset utf8 #124

gunsluo opened this issue Jan 26, 2016 · 4 comments

Comments

@gunsluo
Copy link

gunsluo commented Jan 26, 2016

connection string -> tcp:127.0.0.1:3306*nt_financial/root/jxcec0okm ?

tcp:127.0.0.1:3306*nt_financial/root/jxcec0okm?charset=utf8

@gunsluo
Copy link
Author

gunsluo commented Jan 26, 2016

godrv.Register("SET NAMES utf8")

// Create a connection handler
db, err := sql.Open("mymysql", "test/testuser/TestPasswd9")
checkErr(err)

failed..

@ziutek
Copy link
Owner

ziutek commented Jan 26, 2016

godrv registers "SET NAMES utf8" by default (see Example 7). What do you mean by very descriptive "failed"?

@leeningli
Copy link

leeningli commented Aug 24, 2018

db, err := sql.Open("mymysql", conn)
sql := select * from test;
rows, err := db.Query(sql)
there is no garbled.
but use:db := mysql.New("tcp", "", url, user, pwd, dbname) ,there is garbled

@ziutek
Copy link
Owner

ziutek commented Aug 27, 2018

Try:

db.Query("SET NAMES utf8")

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

3 participants