ziutek / mymysql

MySQL Client API written entirely in Go
Other
735 stars 161 forks source link

how to set charset utf8 #124

Open gunsluo opened 8 years ago

gunsluo commented 8 years ago

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 commented 8 years ago

godrv.Register("SET NAMES utf8")

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

failed..

ziutek commented 8 years ago

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

leeningli commented 6 years ago

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 commented 6 years ago

Try:

db.Query("SET NAMES utf8")