How to use login to access mySQL Workbench database

Hi i have created a mySQL Workbench database and i want to use a login field to access the database.
How can i create a login field using a username and password to enter a mySQL Workbench database?
I want to use it without HTTP webbased application just plan golang language.

1)Enter username > ( if entered username is wrong print “no match found”) >> ask again "Enter username " >> will loop till correct username is found.

2)Enter password > (if entered username is correctly as for password) >> (if entered password is wrong print "wrong password)
>> ask again "Enter password " >> will loop till correct password is found

3)Connect to mySQL Workbench to open database.

Thanks in advance.

I’m not sure i understand your problem. You created a MySql database with MySql Workbench tool, right? Do you intend to make a cli application? You have tried something, where you got messed up?

Im trying to make a golang program that first will ask to enter a username >> enter username.

second question is to enter a password that matches with the corresponding username >> enter password

Finally if the password is enter correctly you could make a connection with the corresponding mySQL database.

example : db, err := sql.Open(“mysql”, “admin:admin@tcp(127.0.0.1:3306)/”)
if err != nil {
panic(err)
}
defer db.Close()

The MySQL data is already created with serveral tables. This is for a cli application.

If you wonder how to read a text from command line you can use fmt.Scanln like in the following example.

package main

import (
	"fmt"
)

func main() {
	var x string
	fmt.Print("Enter text:")
	fmt.Scanln(&x)
	fmt.Println(x)
}

LE: For reading passwords i found this project.

1 Like

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