如何将shell脚本内容写入mysql

 时间:2024-10-15 07:42:55

1、执行命令“yum install tcl”安装tcl工具;

如何将shell脚本内容写入mysql

2、执行命令“yum install expect -y”安装expect;

如何将shell脚本内容写入mysql

3、执行命令“ cd /home ”进入服务器根目录home;

4、执行命令“touch shell_mysql.exp”创建shell脚本交互式文件

如何将shell脚本内容写入mysql

5、执行命令“vim shell_mysql.exp”编辑shell脚本文件并输入以下内容:#!/usr/bin/expectset timeout 2#登陆数据库spawn mysql -uroot -p123456send "\r"#创建数据库并设置utf编码send "create database depart;"send "\r"send "use depart;"send "\r"send "set names utf8;"send "\r"#创建表并设置2个字段send "create table student( id int(10), name varchar(50) ); "send "\r"#插入一条学生信息send "insert into student values(1,'王熙凤');"send "\r"#退出并结束登陆send "quit"send "\r"expect eof

6、执行命令“:wq”保存退出当前文件;

7、执行命令“ chmod -R 777 shell_mysql.exp ”给脚本赋予权限;

如何将shell脚本内容写入mysql

8、执行命令“ ./shell_mysql.exp ”运行shell脚本;

如何将shell脚本内容写入mysql
如何将shell脚本内容写入mysql

9、验证环节:打开桌面客户端Navicat连接数据库能够查看到我们插入的学生信息。至此shell脚本操作mysql数据库的演示已经完成。

如何将shell脚本内容写入mysql
  • 申请典当行牌照条件是什么,申请典当行牌照难吗
  • 微信如何修改登录设备名称?
  • EMUI 8.0界面UX变更,更智能的界面体验
  • 刚开始做电商该如何做
  • 怎样注销多余的微信账号?
  • 热门搜索
    中国传统美德手抄报 数学与生活手抄报 元旦手抄报资料 孝德手抄报 清明时节祭英烈手抄报 足球手抄报 消防安全的手抄报 防火手抄报图片 吸烟有害健康手抄报 初中小组手抄报