Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to operate mysql database in batch through shell script

2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to operate the mysql database in batches through the shell script". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to operate the mysql database in batches through shell scripts".

Create a table statement

= Student form: Student (Sno,Sname,Ssex,Sage,Sdept)-(student number-primary key, name, gender, age Department) = create table student (Sno int (10) NOT NULL COMMENT 'student number', Sname varchar (16) NOT NULL COMMENT 'name', Ssex char (2) NOT NULL COMMENT 'gender', Sage tinyint (2) NOT NULL default'0' COMMENT 'student age', Sdept varchar (16) default NULL COMMENT 'student's department', PRIMARY KEY (Sno)) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8

Bulk insert data script

#! / bin/bash # create by oldboy 20110319 # qq:31333741 MysqlLogin= "mysql-uroot-poldboy" # → defines the command to log in to mysql It is convenient for the following to use # MysqlLogin= "mysql-uroot-poldboy-S / data/3306/mysql.sock" # the way this line is suitable for stand-alone multi-instance database item1 while true # → true means always true do ${MysqlLogin}-e "insert into test.student values (" $I ", 'oldboy" $I ",' masking 21", "$I") "# ${MysqlLogin}-e" insert into oldboy.student values ("$I", 'oldboy "$I"', 'masking grammar 21century computer "$I"'); "# if you can insert multiple tables at the same time, the example I give here is to insert different records, which can be used to do a variety of small tests, which is more suitable for all kinds of operators who do not know how to mysql stored procedures. ((sleep +)) sleep 2; done Thank you for reading, the above is the content of "how to operate the mysql database in batches through the shell script". After the study of this article, I believe you have a deeper understanding of how to operate the mysql database in bulk through the shell script, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report