mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-19 08:19:15 +08:00
fix: 解决数据库创建重命名用户的问题 (#2222)
This commit is contained in:
parent
6e8f22a4a6
commit
6b908d2553
@ -32,7 +32,7 @@ func NewRemote(db Remote) *Remote {
|
||||
func (r *Remote) Create(info CreateInfo) error {
|
||||
createSql := fmt.Sprintf("create database `%s` default character set %s collate %s", info.Name, info.Format, formatMap[info.Format])
|
||||
if err := r.ExecSQL(createSql, info.Timeout); err != nil {
|
||||
if strings.Contains(err.Error(), "ERROR 1007") {
|
||||
if strings.Contains(strings.ToLower(err.Error()), "ERROR 1007") {
|
||||
return buserr.New(constant.ErrDatabaseIsExist)
|
||||
}
|
||||
return err
|
||||
@ -61,6 +61,9 @@ func (r *Remote) CreateUser(info CreateInfo, withDeleteDB bool) error {
|
||||
|
||||
for _, user := range userlist {
|
||||
if err := r.ExecSQL(fmt.Sprintf("create user %s identified by '%s';", user, info.Password), info.Timeout); err != nil {
|
||||
if strings.Contains(strings.ToLower(err.Error()), "error 1396") {
|
||||
return buserr.New(constant.ErrUserIsExist)
|
||||
}
|
||||
if withDeleteDB {
|
||||
_ = r.Delete(DeleteInfo{
|
||||
Name: info.Name,
|
||||
@ -69,9 +72,6 @@ func (r *Remote) CreateUser(info CreateInfo, withDeleteDB bool) error {
|
||||
Permission: info.Permission,
|
||||
ForceDelete: true,
|
||||
Timeout: 300})
|
||||
if strings.Contains(err.Error(), "ERROR 1396") {
|
||||
return buserr.New(constant.ErrUserIsExist)
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
@ -295,14 +295,18 @@ const onChangeConn = async () => {
|
||||
};
|
||||
|
||||
const goRemoteDB = async () => {
|
||||
globalStore.setCurrentDB(currentDB.value.database);
|
||||
if (currentDB.value) {
|
||||
globalStore.setCurrentDB(currentDB.value.database);
|
||||
}
|
||||
router.push({ name: 'MySQL-Remote' });
|
||||
};
|
||||
|
||||
const passwordRef = ref();
|
||||
|
||||
const onSetting = async () => {
|
||||
globalStore.setCurrentDB(currentDB.value.database);
|
||||
if (currentDB.value) {
|
||||
globalStore.setCurrentDB(currentDB.value.database);
|
||||
}
|
||||
router.push({ name: 'MySQL-Setting', params: { type: currentDB.value.type, database: currentDB.value.database } });
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user