mysqlgo

Error 1045 (28000): Access denied for user ''@'localhost' (using password: NO) exit status 1


I am trying to implement the tutorial from https://go.dev/doc/tutorial/database-access on windows 11 machine

I have the set variables using the following code in my workspace terminal

set DBUSER=root
set DBPASS=root

I access these credetials

cnf.User = os.Getenv("DBUSER")
cnf.Passwd = os.Getenv("DBPASS")

I tried uing setx also but same error


Solution

  • Fixed: wrong terminal type

    was using set DBUSER in powershell instead of Commad Prompt.

    For Powershell we should use $Env:DBUSER = "your_username_here"