diff --git a/tools/misc/renamedb.sh b/tools/misc/renamedb.sh index 39068167..1f4fabec 100644 --- a/tools/misc/renamedb.sh +++ b/tools/misc/renamedb.sh @@ -2,11 +2,16 @@ dbuser=root dbpasswd=1000omc@kp! +dbhost=127.0.0.1 -mysql -u$dbuser -p$dbpasswd -e 'create database if not exists $2;' -list_table=$(mysql -u$dbuser -p$dbpasswd -Nse "select table_name from information_schema.TABLES where TABLE_SCHEMA='$1'") +if [ $3 =~ ""]; then + dbhost=$3 +fi + +mysql -u$dbuser -p$dbpasswd -h $dbhost -e "create database if not exists $2;" +list_table=$(mysql -u$dbuser -p$dbpasswd -h $dbhost -Nse "select table_name from information_schema.TABLES where TABLE_SCHEMA='$1'") for table in $list_table do - mysql -u$dbuser -p$dbpasswd -e "rename table $1.$table to $2.$table" + mysql -u$dbuser -p$dbpasswd -h $dbhost -e "rename table $1.$table to $2.$table" done \ No newline at end of file diff --git a/tools/misc/rmexpiredfile.sh b/tools/misc/rmexpiredfile.sh index 8b88938d..7e17caca 100644 --- a/tools/misc/rmexpiredfile.sh +++ b/tools/misc/rmexpiredfile.sh @@ -46,6 +46,3 @@ else fi done echo '删除完成!'>> ${printFile} -———————————————— -版权声明:本文为CSDN博主「Mar5342」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。 -原文链接:https://blog.csdn.net/mar5342/article/details/109121623 \ No newline at end of file