diff --git a/plugins/mysql/conf/my8.0.cnf b/plugins/mysql/conf/my8.0.cnf index ba4f80364..8ccfde4fe 100644 --- a/plugins/mysql/conf/my8.0.cnf +++ b/plugins/mysql/conf/my8.0.cnf @@ -20,7 +20,7 @@ basedir = {$SERVER_APP_PATH} datadir = {$SERVER_APP_PATH}/data log-error = {$SERVER_APP_PATH}/data/error.log server-id = {$SERVER_ID} -sql-mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES +#sql-mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES default_storage_engine = InnoDB @@ -48,7 +48,6 @@ skip_name_resolve=1 #skip-grant-tables log-bin=mysql-bin -binlog_format=mixed slow_query_log=1 slow-query-log-file={$SERVER_APP_PATH}/data/mysql-slow.log long_query_time=10 @@ -84,8 +83,6 @@ replicate-ignore-db = performance_schema replicate-ignore-db = mysql replicate-ignore-db = test -master_info_repository = table -relay_log_info_repository = table innodb_data_home_dir = {$SERVER_APP_PATH}/data innodb_data_file_path = ibdata1:10M:autoextend diff --git a/plugins/mysql/conf/my8.2.cnf b/plugins/mysql/conf/my8.2.cnf new file mode 100644 index 000000000..8ccfde4fe --- /dev/null +++ b/plugins/mysql/conf/my8.2.cnf @@ -0,0 +1,116 @@ +[client] +user = root +#password = your_password +port = 3306 +socket = {$SERVER_APP_PATH}/mysql.sock +default-character-set = UTF8MB4 + +[mysqld] +!include {$SERVER_APP_PATH}/etc/mode/classic.cnf + +sha256_password_private_key_path={$SERVER_APP_PATH}/data/mysql.pem +sha256_password_public_key_path={$SERVER_APP_PATH}/data/mysql.pub +authentication_policy=mysql_native_password + +pid-file = {$SERVER_APP_PATH}/data/mysql.pid +user = mysql +port = 3306 +socket = {$SERVER_APP_PATH}/mysql.sock +basedir = {$SERVER_APP_PATH} +datadir = {$SERVER_APP_PATH}/data +log-error = {$SERVER_APP_PATH}/data/error.log +server-id = {$SERVER_ID} +#sql-mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES + +default_storage_engine = InnoDB + +key_buffer_size = 8M +table_open_cache = 32 +sort_buffer_size = 256K +net_buffer_length = 4K +read_buffer_size = 128K +read_rnd_buffer_size = 256K +myisam_sort_buffer_size = 4M +thread_cache_size = 4 +lower_case_table_names=0 +tmp_table_size = 8M +character-set-server = UTF8MB4 + +max_connections = 500 +max_connect_errors = 100 +open_files_limit = 2560 +max_allowed_packet = 128M + +skip_name_resolve=1 +#skip-networking +#skip-external-locking +#loose-skip-innodb +#skip-grant-tables + +log-bin=mysql-bin +slow_query_log=1 +slow-query-log-file={$SERVER_APP_PATH}/data/mysql-slow.log +long_query_time=10 +#log_queries_not_using_indexes=1 +#log_slow_admin_statements=1 +#log_slow_replica_statements=1 +binlog_expire_logs_seconds=2592000 + +relay-log=mdserver +relay-log-index=mdserver + +#多主设置 +#auto_increment_offset=2 +#auto_increment_increment=2 + +#master +#sync_binlog=1 + +#binlog-do-db +binlog-ignore-db = test +binlog-ignore-db = mysql +binlog-ignore-db = information_schema +binlog-ignore-db = performance_schema + +#slave +log_replica_updates = 1 +# Prevent replication from starting automatically with MySQL +#skip_replica_start = 1 +#replicate-do-db +replica_skip_errors=1062,1396 +replicate-ignore-db = information_schema +replicate-ignore-db = performance_schema +replicate-ignore-db = mysql +replicate-ignore-db = test + + +innodb_data_home_dir = {$SERVER_APP_PATH}/data +innodb_data_file_path = ibdata1:10M:autoextend +innodb_log_group_home_dir = {$SERVER_APP_PATH}/data +innodb_buffer_pool_size = 16M +#innodb_log_file_size = 5M +innodb_redo_log_capacity=10485760 +innodb_log_buffer_size = 8M +innodb_flush_log_at_trx_commit = 1 +innodb_lock_wait_timeout = 120 +innodb_max_dirty_pages_pct = 90 +innodb_read_io_threads = 1 +innodb_write_io_threads = 1 +innodb_file_per_table=1 + +secure-file-priv={$SERVER_APP_PATH}/tmp + +[mysqldump] +quick + +[mysql] +no-auto-rehash + +[myisamchk] +key_buffer_size = 20M +sort_buffer_size = 20M +read_buffer = 2M +write_buffer = 2M + +[mysqlhotcopy] +interactive-timeout \ No newline at end of file diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py index b4c7a0ff9..e11d884fb 100755 --- a/plugins/mysql/index.py +++ b/plugins/mysql/index.py @@ -116,6 +116,16 @@ def getErrorLogsFile(): tmp = re.search(rep, content) return tmp.groups()[0].strip() +def getAuthPolicy(): + file = getConf() + content = mw.readFile(file) + rep = 'authentication_policy\s*=\s*(.*)' + tmp = re.search(rep, content) + if tmp: + return tmp.groups()[0].strip() + # caching_sha2_password + return 'mysql_native_password' + def getInitdTpl(version=''): path = getPluginDir() + '/init.d/mysql' + version + '.tpl' @@ -530,6 +540,9 @@ def initMysqlPwd(): def initMysql8Pwd(): time.sleep(8) + + auth_policy = getAuthPolicy() + serverdir = getServerDir() myconf = serverdir + "/etc/my.cnf" @@ -543,7 +556,7 @@ def initMysql8Pwd(): alter_root_pwd = alter_root_pwd + \ "alter user 'root'@'localhost' IDENTIFIED by '" + pwd + "';" alter_root_pwd = alter_root_pwd + \ - "alter user 'root'@'localhost' IDENTIFIED WITH mysql_native_password by '" + pwd + "';" + "alter user 'root'@'localhost' IDENTIFIED WITH "+auth_policy+" by '" + pwd + "';" alter_root_pwd = alter_root_pwd + "flush privileges;" cmd_pass = serverdir + '/bin/mysqladmin --defaults-file=' + \ @@ -620,6 +633,8 @@ def my8cmd(version, method): isInited = initMysql57Data() elif version == '8.0': isInited = initMysql8Data() + elif version == '8.2': + isInited = initMysql8Data() if not isInited: @@ -660,7 +675,7 @@ def my8cmd(version, method): def appCMD(version, action): makeInitRsaKey(version) - if version == '8.0' or version == '5.7': + if float(version) >= 5.7: status = my8cmd(version, action) else: status = myOp(version, action) @@ -2123,12 +2138,14 @@ def addMasterRepSlaveUser(version=''): pdb = pMysqlDb() psdb = pSqliteDb('master_replication_user') + auth_policy = getAuthPolicy() + if psdb.where("username=?", (username)).count() > 0: return mw.returnJson(False, '用户已存在!') if version == "8.0": sql = "CREATE USER '" + username + \ - "' IDENTIFIED WITH mysql_native_password BY '" + password + "';" + "' IDENTIFIED WITH "+auth_policy+" BY '" + password + "';" pdb.execute(sql) sql = "grant replication slave on *.* to '" + username + "'@'%';" result = pdb.execute(sql) diff --git a/plugins/mysql/install.sh b/plugins/mysql/install.sh index 1b747fd02..da748592f 100755 --- a/plugins/mysql/install.sh +++ b/plugins/mysql/install.sh @@ -5,6 +5,9 @@ export PATH # 手动主从设置 # https://www.cnblogs.com/whiteY/p/17331882.html +# cd /www/server/mdserver-web/plugins/mysql && bash install.sh install 8.2 +# cd /www/server/mdserver-web && source bin/activate && python3 /www/server/mdserver-web/plugins/mysql/index.py try_slave_sync_bugfix {} + curPath=`pwd` rootPath=$(dirname "$curPath") rootPath=$(dirname "$rootPath") diff --git a/plugins/mysql/js/mysql.js b/plugins/mysql/js/mysql.js index bfb8ea425..c39747c03 100755 --- a/plugins/mysql/js/mysql.js +++ b/plugins/mysql/js/mysql.js @@ -496,7 +496,6 @@ function setRootPwd(type, pwd){ var rdata = $.parseJSON(data.data); showMsg(rdata.msg,function(){ dbList(); - $('.layui-layer-close1').click(); },{icon: rdata.status ? 1 : 2}); }); return; @@ -508,7 +507,7 @@ function setRootPwd(type, pwd){ title: '修改数据库密码', closeBtn: 1, shift: 5, - btn:["提交","关闭"], + btn:["提交", "复制ROOT密码", "关闭"], shadeClose: true, content: "
\
\ @@ -518,8 +517,19 @@ function setRootPwd(type, pwd){
\ \
", - yes:function(){ - setRootPwd(1); + yes:function(layerIndex){ + var password = $("#MyPassword").val(); + myPost('set_root_pwd', {password:password}, function(data){ + var rdata = $.parseJSON(data.data); + showMsg(rdata.msg,function(){ + layer.close(layerIndex); + },{icon: rdata.status ? 1 : 2}); + }); + }, + btn2:function(){ + var password = $("#MyPassword").val(); + copyText(password); + return false; } }); } diff --git a/plugins/mysql/versions/8.0/install.sh b/plugins/mysql/versions/8.0/install.sh index d03d84302..dcfbb3e4a 100755 --- a/plugins/mysql/versions/8.0/install.sh +++ b/plugins/mysql/versions/8.0/install.sh @@ -159,7 +159,7 @@ Install_mysql() apt install -y libssl-dev apt install -y libgssglue-dev apt install -y software-properties-common - add-apt-repository ppa:ubuntu-toolchain-r/test + add-apt-repository -y ppa:ubuntu-toolchain-r/test LIBTIRPC_VER=`pkg-config libtirpc --modversion` if [ ! -f ${mysqlDir}/libtirpc_1.3.3.orig.tar.bz2 ];then diff --git a/plugins/mysql/versions/8.2/install.sh b/plugins/mysql/versions/8.2/install.sh index 07959469d..70f936bb0 100755 --- a/plugins/mysql/versions/8.2/install.sh +++ b/plugins/mysql/versions/8.2/install.sh @@ -153,13 +153,13 @@ Install_mysql() echo $WHERE_DIR_GPP fi - if [ "$OSNAME" == "ubuntu" ] && [ "$VERSION_ID" == "18.04" ];then + if [ "$OSNAME" == "ubuntu" ];then apt install -y libudev-dev apt install -y libtirpc-dev apt install -y libssl-dev apt install -y libgssglue-dev apt install -y software-properties-common - add-apt-repository ppa:ubuntu-toolchain-r/test + add-apt-repository -y ppa:ubuntu-toolchain-r/test LIBTIRPC_VER=`pkg-config libtirpc --modversion` if [ ! -f ${mysqlDir}/libtirpc_1.3.3.orig.tar.bz2 ];then diff --git a/route/static/app/public.js b/route/static/app/public.js index 2db6f27ea..909c02d35 100755 --- a/route/static/app/public.js +++ b/route/static/app/public.js @@ -74,7 +74,7 @@ function toUnixTime(txt){ function randomStrPwd(b) { b = b || 32; - var c = "AaBbCcDdEeFfGHhiJjKkLMmNnPpRSrTsWtXwYxZyz2345678"; + var c = "AaBbCcDdEeFfGHhiJjKkLMmNnPpRSrTsWtXwYxZyz2345678&!@%"; var a = c.length; var d = ""; for(i = 0; i < b; i++) { @@ -164,7 +164,7 @@ $(".menu-icon").click(function() { $(".sidebar-scroll").toggleClass("sidebar-close"); $(".main-content").toggleClass("main-content-open"); if($(".sidebar-close")) { - $(".sub-menu").find(".sub").css("display", "none") + $(".sub-menu").find(".sub").css("display", "none"); } });