[英]Delete mysql table data (Bash Script)
I was wondering how to delete the values in a MySQL database table from bash.我想知道如何从 bash 中删除 MySQL 数据库表中的值。
I have a database called "database" and a table in that database called "table".我有一个名为“database”的数据库和一个名为“table”的数据库中的表。
Now I want to dump and clear the database from a bash script.现在我想从 bash 脚本转储和清除数据库。
How can I delete the values?如何删除值?
I am using:我在用:
mysqldump database > $DB_BACKUP/01/table-`date +%Y-%m-%d` (to dump)
and now trying to现在试图
DELETE FROM database.table WHERE filed < CURDATE()-5
mysql -Bse 'DELETE FROM database.table WHERE filed < CURDATE()- 5'
or要么
mysql -Bse 'DELETE FROM table WHERE filed < CURDATE()- 5' database
mysql --help
-B, --batch Don't use history file. -B, --batch不要使用历史文件。 Disable interactive behavior.
禁用交互行为。 starts with this option ENABLED by default!
默认情况下以启用此选项开始! Disable with
禁用
-s, --silent Be more silent. -s, --silent更安静。 Print results with a tab as separator, Buffer for TCP/IP and socket communication
使用制表符作为分隔符打印结果,用于 TCP/IP 和套接字通信的缓冲区
-e, --execute=name Execute command and quit. -e, --execute=name执行命令并退出。 (Disables --force and history file)
(禁用 --force 和历史文件)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.