Error 1045: Access denied for user (MySql)

I’ve recently started self teaching Go and have run into this error, perhaps I’m not understanding the correct function of the mysql driver used in the Golang tutorial for db connection.

db, err := sql.Open("mysql", "user:pass@tcp(mywebserver)/networking_test")

The error is returning my local ip address stating access denied while using password. Is the SQL query never leaving my network? Full code provided below, full error included below that.

package main

import (



    _ "mysql"


    func main() {

        fmt.Println("Go MySQL Tutorial")

        db, err := sql.Open("mysql", "user:npass@tcp(mywebserver)/networking_test")

        if err != nil {



        defer db.Close()

        dbuser, err := db.Query("SELECT user FROM authentication")

        if err != nil {



        defer dbuser.Close()

    //Error - panic: Error 1045: Access denied for user 'networkuser'@'LOCALHOST(using password: YES)

Can you access mysql from terminal?

For Ubuntu Linux you can type:
sudo mysql -u username -p

Unfortunately I’m only running Windows at the moment.Is there a built in SQL feature in command prompt?

mysql-cli GRANT cmd?

Yes, it must be the same.
" To launch the client, enter the following command in a Command Prompt window: mysql -u root -p ."

or can you acceess your database with mysql workbench with same username and password?

Try to access this way, because you problem looks like it is about mysql configuration.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.