diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py
index 0a0e7132a..557206904 100755
--- a/plugins/mysql/index.py
+++ b/plugins/mysql/index.py
@@ -359,8 +359,40 @@ def isSqlError(mysqlMsg):
def syncGetDatabases():
pdb = pMysqlDb()
- data = pdb.query('show variables')
- return ''
+ psdb = pSqliteDb('databases')
+ data = pdb.query('show databases')
+ isError = isSqlError(data)
+ if isError != None:
+ return isError
+ users = pdb.query(
+ "select User,Host from mysql.user where User!='root' AND Host!='localhost' AND Host!=''")
+ nameArr = ['information_schema', 'performance_schema', 'mysql', 'sys']
+ n = 0
+ for value in data:
+ b = False
+ for key in nameArr:
+ if value[0] == key:
+ b = True
+ break
+ if b:
+ continue
+ if psdb.where("name=?", (value[0],)).count():
+ continue
+ host = '127.0.0.1'
+ for user in users:
+ if value[0] == user[0]:
+ host = user[1]
+ break
+
+ ps = public.getMsg('INPUT_PS')
+ if value[0] == 'test':
+ ps = public.getMsg('DATABASE_TEST')
+ addTime = time.strftime('%Y-%m-%d %X', time.localtime())
+ if psdb.table('databases').add('name,username,password,accept,ps,addtime', (value[0], value[0], '', host, ps, addTime)):
+ n += 1
+
+ msg = public.getInfo('本次共从服务器获取了{1}个数据库!', (str(n),))
+ return public.returnJson(True, msg)
if __name__ == "__main__":
func = sys.argv[1]
diff --git a/plugins/mysql/js/mysql.js b/plugins/mysql/js/mysql.js
index 7b06214da..4044b57b1 100755
--- a/plugins/mysql/js/mysql.js
+++ b/plugins/mysql/js/mysql.js
@@ -94,39 +94,6 @@ function myPort(){
});
}
-function dbList(){
- var con = '
\
- \
- \
- \
- \
- \
- \
- \
-
\
-
\
-
\
-
\
-
数据库名
\
-
用户名
\
-
密码
\
-
备份
备注
\
-
操作
\
- \
-
\
-
\
-
1共2条数据
\
-
\
- 同步选中\
- 同步所有\
- 从服务器获取\
-
\
-
\
-
';
-
- $(".soft-man-con").html(con);
-}
-
//设置二进制日志
function SetBinLog() {
var loadT = layer.msg(lan.public.the, { icon: 16, time: 0, shade: 0.3 });
@@ -444,4 +411,46 @@ function comMySqlMem() {
var b = sort_buffer_size + read_buffer_size + read_rnd_buffer_size + join_buffer_size + thread_stack + binlog_cache_size
var memSize = a + max_connections * b
$("input[name='memSize']").val(memSize.toFixed(2));
-}
\ No newline at end of file
+}
+
+function dbList(){
+ var con = '