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腳本