zoukankan      html  css  js  c++  java
  • 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 程序拒绝执行

  • 相关阅读:
    Python+Selenium+PhantomJS下载JavaScript异步加载网页
    Java模拟post提交表单数据
    在nltk中调用stanfordparser处理中文
    Clustering text documents using k-means
    Classification of text documents: using a MLComp dataset
    Analyzing the Meaning of Sentences
    Identifying Dialogue Act Type
    jquery $.ajax()获取服务器上的json数据
    关于ie6中存在的最小的高度
    让两个元素水平对齐
  • 原文地址:https://www.cnblogs.com/fanweisheng/p/11328111.html
Copyright © 2011-2022 走看看