Tuesday, May 14, 2019

MySQL Passwords

I'll never remember this unless I write it down here. And hey, maybe it will help somebody else.

Problem:

  • MySQL version 8+
  • github.com/go-sql-driver/mysql
  • db, err = sql.Open("mysql", "username:password@/database")
    (no error)
  • query, err := db.Query("SELECT * FROM TABLE")
    this authentication plugin is not supported

Solution:

mysql> alter user 'username'@'localhost' identified with mysql_native_password by 'password';

See also: https://github.com/go-sql-driver/mysql/issues/785

No comments: