|
|
|
@ -75,7 +75,8 @@ func openMariaDBConnection() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func createMariaDbUser(uid string, pw string) bool {
|
|
|
|
|
createUserStmt := `CREATE OR REPLACE USER '%s'@'%%' IDENTIFIED BY '%s';`
|
|
|
|
|
createUserStmt := "CREATE OR REPLACE USER '%[1]s'@'%%' IDENTIFIED BY '%[2]s';\n"
|
|
|
|
|
createUserStmt += "GRANT ALL ON `%[1]s\\_%%`.* TO '%[1]s'@'%%';"
|
|
|
|
|
createUserStmt = fmt.Sprintf(createUserStmt, uid, pw)
|
|
|
|
|
log.Println(createUserStmt)
|
|
|
|
|
_, err := mariaDB.Exec(createUserStmt)
|
|
|
|
@ -89,11 +90,6 @@ func createMariaDbUser(uid string, pw string) bool {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func createMariaDbDatabasesForUser(uid string) bool {
|
|
|
|
|
// _, err := mariaDB.Exec(`DROP USER IF EXISTS '?';
|
|
|
|
|
// CREATE USER '?'@'%';
|
|
|
|
|
// DROP DATABASE IF EXISTS ?_W19_20;
|
|
|
|
|
// CREATE DATABASE ?_W19_20;
|
|
|
|
|
// GRANT ALL ON ?_W19_20.* TO '?'@'%' IDENTIFIED BY '?';`, uid, uid, uid, uid, uid, uid, pw)
|
|
|
|
|
sqlFilePath := "../../sql/"
|
|
|
|
|
files, err := ioutil.ReadDir(sqlFilePath)
|
|
|
|
|
if err != nil {
|
|
|
|
|