Cannot login locally to SYS
tredoe opened this issue · comments
Describe the bug
I get the error:
ORA-28009 connection to sys should be as sysdba or sysoper
but I unknow how to add "as sysdba" at the connection string.
To Reproduce
package main
import (
"database/sql"
"fmt"
"log"
_ "gopkg.in/goracle.v2"
)
const (
dbname = "XEPDB1"
user = "SYS"
pass = "***"
)
func main() {
db, err := connectDB()
if err != nil {
log.Fatal("Connect Error:\n" + err.Error())
}
if err = db.Ping(); err != nil {
log.Fatal("Ping Error:\n" + err.Error())
}
defer db.Close()
fmt.Println("Connected: ok")
}
func connectDB() (*sql.DB, error) {
driver := "goracle"
connString := fmt.Sprintf("oracle://%s:%s@127.0.0.1/%s", user, pass, dbname)
return sql.Open(driver, connString)
}
Your oracle client version
Oracle Database 18c Express Edition Release 18.0.0.0.0
Your goracle version
v2.22.4
Your go version
go version go1.13.4 windows/amd64
Your gcc version
gcc --version
gcc (x86_64-win32-seh-rev0, Built by MinGW-W64 project) 8.1.0
Machine:
- OS: Windows
- Architecture amd64
- Version: 10
The connection parameter options are described in the documentation for the package
https://godoc.org/gopkg.in/goracle.v2
At the top you can see how to set sysdba for the URI format. In your example you would change the connection string to "oracle://%s:%s@127.0.0.1/%s?sysdba=1"
It works!
Thank you very much!