利用shell脚本运行MYSQL语句,并在mysql中执行shell脚本

利用shell脚本运行MYSQL语句,并在mysql中执行shell脚本

游戏|数码彩彩2024-04-07 7:43:30418A+A-

1,先手动测试shell

linux下面利用shell脚本运行MySQL语句,并在mysql中执行shell脚本

shell脚本:(将最新产生的MYSQL错误日志导到数据表中)

bin/mysql -u root -p11111 <<EOF

use MysqlCenter;

create TEMPORARY table Errlog_info_temp(loginfo varchar(2000),id int primary key AUTO_INCREMENT);

LOAD DATA LOCAL INFILE '/usr/local/mysql/data/loDB192168000046.err' INTO TABLE Errlog_info_temp;

insert into Errlog_info(id,loginfo) select ID,loginfo from Errlog_info_temp where id not in (select id from Errlog_info);

drop table Errlog_info_temp;

EOF

2.提封装成.sh文件并提权

chmod u+x SHELL脚本名

3.执行shell脚本 ./shell.sh

在mysql中运行shell

1. system /usr/local/mysql/shell2.sh

Linux下面利用shell脚本运行MYSQL语句,并在mysql中执行shell脚本

点击这里复制本文地址 版权声明:本文内容由网友提供,该文观点仅代表作者本人。本站(https://www.angyang.net.cn)仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

昂扬百科 © All Rights Reserved.  渝ICP备2023000803号-3网赚杂谈