If I run the following from command prompt...
mysql -h xxx.xxx.xxx.xxx -u myuser -p mydb
I can access the database and successfully run a query from the sql> command prompt
However, when I use the database/sql
package in Golang get the following...
[0/0]0x0Error 1045: Access denied for user 'myuser'@'xxx.xxx.xxx.xxx' (using password: YES)
Please see code below...
db, err := sql.Open("mysql", myuser:mypassword@tcp(xxx.xxx.xxx.xxx:3306)/mydb)
if err != nil {
color.Red(err.Error())
}
var objects []map[string]interface{}
rows, err := db.Query("select * from mytable" , args...)
if err != nil {
return nil, err
}
Please note the db
var seems fine as if it connects to the database, it's when i try to populate the rows var i get the error.
Also i created unit tests which create a database and table and test a query these all work fine.
Al firewalls etc are off.
so to summarise...
Remote + Command Prompt - works
local + golang - is fine
Remote + golang - gets the error