linux 防止误操作 mysql 数据库技巧
mysql 帮助说明
1[oldboy_c64 ~]# mysql --help|grep dummy
2 -U, --i-am-a-dummy Synonym for option --safe-updates, -U.
3i-am-a-dummy FALSE
在 mysql 命令加上选项-U 后,当发出没有 WHERE 或 LIMIT 关键字的 UPDATE 或 DELETE 时,
mysql 程序就会拒绝执行
[oldboy_c64 ~]# mysql -uroot -poldboy123 -S /data/3306/mysql.sock –U
1
Welcome to the MySQL monitor. Commands end with ; or \g.
2
Your MySQL connection id is 14
3
Server version: 5.5.32-log MySQL Community Server (GPL)
4
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
5
Oracle is a registered trademark of Oracle Corporation and/or its
6
affiliates. Other names may be trademarks of their respective
7
owners.
8
Type 'help;' or '\h' for help. Type '\c' to
clear the current input statement.
9
mysql> delete from oldboy.student;
10
ERROR 1175 (HY000): You are using safe update mode and you tried to update a
11
table without a
WHERE that uses a KEY column
12
mysql> quit
13
Bye
103
提示:不加条件无法删除,目的达到。
3、做成别名防止老大和 DBA 误操作
1 [oldboy_c64 ~]# alias mysql='mysql -U'
2 [oldboy_c64 ~]# mysql -uroot -poldboy123 -S /data/3306/mysql.sock
3 Welcome to the MySQL monitor. Commands end with ; or \g.
4 Your MySQL connection id is 15
5 Server version: 5.5.32-log MySQL Community Server (GPL)
6 Type 'help;' or '\h' for help. Type '\c' to
clear the current input statement.
7 mysql> delete from oldboy.student;
8 ERROR 1175 (HY000): You are using safe update mode and you tried to update a
9 table without a WHERE that uses a
KEY column
10mysql> delete from oldboy.student where Sno=5;
11Query OK, 1 row affected (0.02 sec)
12mysql> quit
104
13Bye
14[oldboy_c64 ~]# echo "alias mysql='mysql -U'" >>/etc/profile
15[oldboy_c64 ~]# . /etc/profile
16[oldboy_c64 ~]# tail -1 /etc/profile
alias mysql='mysql -U'
结论:
在 mysql 命令加上选项-U 后,当发出没有 WHERE 或 LIMIT 关键字的 UPDATE 或 DELETE 时,
mysql 程序拒绝执行
linux 防止误操作 mysql 数据库技巧的更多相关文章
- (转)防止人为误操作MySQL数据库技巧一例
原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://oldboy.blog.51cto.com/2561410/1321061 防止人 ...
- 【MySQL】如何最大程度防止人为误操作MySQL数据库?这次我懂了!!
写在前面 今天,一位哥们打电话来问我说误操作了他们公司数据库中的数据,如何恢复.他原本的想法是登录数据库update一个记录,结果忘了加where条件,于是悲剧发生了.今天,我们不讲如何恢复误操作的数 ...
- 基于MySQL的-u选项实现如何最大程度防止人为误操作MySQL数据库
在mysql命令加上选项-U后,当发出没有WHERE或LIMIT关键字的UPDATE或DELETE时,MySQL程序就会拒绝执行.那么,我们基于MySQL提供的这项设置,就可以轻松实现如何最大程度防止 ...
- linux系统下操作mysql数据库常见命令
一. 备份数据库(如: test): ①可直接进入后台即可.(MySQL的默认目录:/var/lib/mysql ) ②输入命令: [root@obj mysql]# mysqldump -u roo ...
- linux命令行操作mysql数据库明细
连接数据库==> mysql -uroot -p 输入root密码 进入mysql操作后 下面的命令不要忘了最后结尾的; 1.选择数据库命令: use <数据库名> 2.查看表的引擎 ...
- C++操作Mysql数据库/Linux下
本文链接:https://blog.csdn.net/Tanswer_/article/details/72796570想用C++写项目,数据库是必须的,所以这两天学了一下C++操作Mysql数据库的 ...
- python【第十二篇下】操作MySQL数据库以及ORM之 sqlalchemy
内容一览: 1.Python操作MySQL数据库 2.ORM sqlalchemy学习 1.Python操作MySQL数据库 2. ORM sqlachemy 2.1 ORM简介 对象关系映射(英语: ...
- Linux C语言操作MySQL
原文:Linux C语言操作MySQL 1.MySQL数据库简介 MySQL是一个开源码的小型关系数据库管理系统,体积小,速度快,总体成本低,开源.MySQL有以下特性: (1) 使用C和C++编写, ...
- Go语言操作MySQL数据库
Go语言操作MySQL数据库 MySQL是一个关系型数据库管理系统,由瑞典MySQL AB 公司开发,目前属于 Oracle 旗下产品.MySQL 是最流行的关系型数据库管理系统之一,在 WEB 应用 ...
随机推荐
- [C++基础] 纯虚函数
整理摘自https://blog.csdn.net/ithomer/article/details/6031329 1. 申明格式 class CShape { public: ; }; 在普通的虚函 ...
- Spring Data Jpa (二)JPA基础查询
介绍Spring Data Common里面的公用基本方法 (1)Spring Data Common的Repository Repository位于Spring Data Common的lib里面, ...
- Java数据结构之排序---快速排序
快速排序是对冒泡排序的一种改进. 快速排序的基本思想: 假设我们以升序为例,它的执行流程可以概括为,每一趟选择当前所有子序列中的一个关键字(通常我们选择第一个,下述代码实现选择的也是第一个数)作为枢纽 ...
- [LeetCode]-DataBase-Nth Highest Salary
Write a SQL query to get the nth highest salary from the Employee table. +----+--------+ | Id | Sala ...
- Oracle JET mobile cordove navigator.app对象
在使用 Oracle JET 开发 webapp 时,会使用到 ojrouter ,ojrouter 默认含有历史记录推送功能.在调试 Android 时会发现返回键总是返回到上一次浏览记录(App ...
- Buffer-Overflow Vulnerability Lab
实验概述 Buffer overflow 定义 Buffer overflow is defined as the condition in which a program attempts to ...
- lr中用C语言比较两个字符串变量
以下脚本,定义两个一样的字符数组,对比后,打印出result的值: Action() { int result; char string1[] = "We can see the strin ...
- NDK undefined reference to 'rand'
NDK 编译 结果报错undefined reference to 'rand' 最怪异的是armeabi-v7a armeabi的情况下有问题 但是arm64-v8a编译正常,用网上说的添加头文件s ...
- kafka多线程消费
建立kafka消费类ConsumerRunnable ,实现Runnable接口: import com.alibaba.fastjson.JSON; import com.alibaba.fastj ...
- 2018.03.29 python-pandas transform/apply 的使用
#一般化的groupby方法:apply df = pd.DataFrame({'data1':np.random.rand(5), 'data2':np.random.rand(5), 'key1' ...