-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
x/website: MySQL config is incorrect in the database access tutorial. #49134
Comments
maybe it should use Also for doc/database/open-handle cc @stevetraut |
Change https://golang.org/cl/358294 mentions this issue: |
This is still an issue unless I'm looking at an outdated version of this page: https://go.dev/doc/tutorial/database-access... I don't see the change to reference cfg := mysql.Config{
User: os.Getenv("DBUSER"),
Passwd: os.Getenv("DBPASS"),
Net: "tcp",
Addr: "127.0.0.1:3306",
DBName: "recordings",
} |
The Go MySQL tutorial fails without: @dr2chase or @eliben - Could you sponsor this doc change, or review with team? Please note during the 2 year window this issue is open, Go Twitter promoted it: https://twitter.com/golang/status/1641133293180420116 |
Thanks for bringing this to our attention, @sprive I note that an earlier CL addressing this already exists in Gerrit: https://go-review.googlesource.com/c/website/+/358294 (it's mentioned here upthread). I will take a look at the CL and leave some comments - please help review it and update it, if needed. |
MySQL config code should use
AllowNativePasswords: true
.The tutorial https://golang.org/doc/tutorial/database-access describes MySQL config code as the following:
But, it causes an error like the following:
To run the code correctly, we should add
AllowNativePasswords: true
to the MySQL config or usemsql.NewConfig
method instead of creatingmysql.Config
struct directly. Please see the following full config code.The correct code is:
or
See also:
AllowNativePassword
in DSN param string be true by default. go-sql-driver/mysql#644The text was updated successfully, but these errors were encountered: