mirror of https://github.com/1Panel-dev/1Panel
feat: mysql分成两个应用
parent
581c940336
commit
7dad47464d
|
@ -16,17 +16,31 @@
|
|||
],
|
||||
"items": [
|
||||
{
|
||||
"key": "mysql",
|
||||
"name": "Mysql",
|
||||
"key": "mysql5.7",
|
||||
"name": "Mysql5.7",
|
||||
"tags": ["Datastore"],
|
||||
"versions": ["5.7.39","8.0.30"],
|
||||
"versions": ["5.7.39"],
|
||||
"short_desc": "常用关系型数据库",
|
||||
"icon": "mysql.png",
|
||||
"author": "Oracle",
|
||||
"type": "runtime",
|
||||
"required": [""],
|
||||
"crossVersionUpdate": false,
|
||||
"limit": 0,
|
||||
"limit": 1,
|
||||
"source": "https://www.mysql.com"
|
||||
},
|
||||
{
|
||||
"key": "mysql8.0",
|
||||
"name": "Mysql8.0",
|
||||
"tags": ["Datastore"],
|
||||
"versions": ["8.0.30"],
|
||||
"short_desc": "常用关系型数据库",
|
||||
"icon": "mysql.png",
|
||||
"author": "Oracle",
|
||||
"type": "runtime",
|
||||
"required": [""],
|
||||
"crossVersionUpdate": false,
|
||||
"limit": 1,
|
||||
"source": "https://www.mysql.com"
|
||||
},
|
||||
{
|
||||
|
|
|
@ -23,4 +23,14 @@ http {
|
|||
keepalive_timeout 65;
|
||||
|
||||
include /etc/nginx/conf.d/*.conf;
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name 127.0.0.1;
|
||||
allow 127.0.0.1;
|
||||
location /nginx_status {
|
||||
stub_status on;
|
||||
access_log off;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -46,26 +46,30 @@ func execDockerCommand(database model.AppDatabase, dbInstall model.AppInstall, o
|
|||
Auth: auth,
|
||||
DbParam: dbConfig,
|
||||
}
|
||||
_, err := cmd.Exec(getSqlStr(database.Key, dbInstall.Version, op, execConfig))
|
||||
_, err := cmd.Exec(getSqlStr(database.Key, op, execConfig))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func getSqlStr(key, version string, operate DatabaseOp, exec dto.ContainerExec) string {
|
||||
func getSqlStr(key string, operate DatabaseOp, exec dto.ContainerExec) string {
|
||||
var str string
|
||||
param := exec.DbParam
|
||||
switch key {
|
||||
case "mysql":
|
||||
case "mysql5.7":
|
||||
if operate == Add {
|
||||
if common.CompareVersion(version, "8.0") {
|
||||
str = fmt.Sprintf("docker exec -i %s mysql -uroot -p%s -e \"CREATE USER '%s'@'%%' IDENTIFIED BY '%s';\" -e \"create database %s;\" -e \"GRANT ALL ON %s.* TO '%s'@'%%';\" -e \"FLUSH PRIVILEGES;\"",
|
||||
exec.ContainerName, exec.Auth.RootPassword, param.DbUser, param.Password, param.DbName, param.DbName, param.DbUser)
|
||||
} else {
|
||||
str = fmt.Sprintf("docker exec -i %s mysql -uroot -p%s -e \"CREATE USER '%s'@'%%' IDENTIFIED BY '%s';\" -e \"create database %s;\" -e \"GRANT ALL ON %s.* TO '%s'@'%%' IDENTIFIED BY '%s';\" -e \"FLUSH PRIVILEGES;\"",
|
||||
exec.ContainerName, exec.Auth.RootPassword, param.DbUser, param.Password, param.DbName, param.DbName, param.DbUser, param.Password)
|
||||
}
|
||||
str = fmt.Sprintf("docker exec -i %s mysql -uroot -p%s -e \"CREATE USER '%s'@'%%' IDENTIFIED BY '%s';\" -e \"create database %s;\" -e \"GRANT ALL ON %s.* TO '%s'@'%%' IDENTIFIED BY '%s';\" -e \"FLUSH PRIVILEGES;\"",
|
||||
exec.ContainerName, exec.Auth.RootPassword, param.DbUser, param.Password, param.DbName, param.DbName, param.DbUser, param.Password)
|
||||
}
|
||||
if operate == Delete {
|
||||
str = fmt.Sprintf("docker exec -i %s mysql -uroot -p%s -e \"drop database %s;\" -e \"drop user %s;\" ",
|
||||
exec.ContainerName, exec.Auth.RootPassword, param.DbName, param.DbUser)
|
||||
}
|
||||
case "mysql8.0":
|
||||
if operate == Add {
|
||||
str = fmt.Sprintf("docker exec -i %s mysql -uroot -p%s -e \"CREATE USER '%s'@'%%' IDENTIFIED BY '%s';\" -e \"create database %s;\" -e \"GRANT ALL ON %s.* TO '%s'@'%%';\" -e \"FLUSH PRIVILEGES;\"",
|
||||
exec.ContainerName, exec.Auth.RootPassword, param.DbUser, param.Password, param.DbName, param.DbName, param.DbUser)
|
||||
}
|
||||
if operate == Delete {
|
||||
str = fmt.Sprintf("docker exec -i %s mysql -uroot -p%s -e \"drop database %s;\" -e \"drop user %s;\" ",
|
||||
|
|
Loading…
Reference in New Issue