-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
panic: pq: password authentication failed for user "bond" #28
Comments
same issue |
Had the same issue! I have not tested it in further lectures, but I was able to connect following this article: https://www.calhoun.io/connecting-to-a-postgresql-database-with-gos-database-sql-package/ My code ended up looking something like this:
|
In my case, I had misconfigured my local postgres server. Here's the fix: Find the SHOW hba_file; Edit it...
Make sure local connections are set to password:
Restart postgres:
|
I keep getting the following error: panic: pq: password authentication failed for user "bond"
I cannot find what's wrong with the code, as it's the one that was used in the course, and in the course it ran perfectly.
Can you find the problem?
GO CODE:
package main
import (
"database/sql"
"fmt"
)
func main() {
db, err := sql.Open("postgres", "postgres://bond:password@localhost/bookstore?sslmode=disable")
if err != nil {
panic(err)
}
defer db.Close()
}
postgreSQL CODE:
postgres=# CREATE DATABASE bookstore;
CREATE DATABASE
postgres=# CREATE USER bond WITH PASSWORD 'password';
CREATE ROLE
postgres=# GRANT ALL PRIVILEGES ON DATABASE bookstore to bond;
GRANT
The text was updated successfully, but these errors were encountered: