网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

MySQL中怎么防止无where条件的update操作

本篇文章为大家展示了MySQL中怎么防止无where条件的update操作,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。

成都创新互联10年专注成都高端网站建设定制网站设计服务,为客户提供专业的成都网站制作,成都网页设计,成都网站设计服务;成都创新互联服务内容包含成都网站建设,小程序开发,软件开发,网络营销推广,网络运营服务及企业形象设计;成都创新互联拥有众多专业的高端网站制作开发团队,资深的高端网页设计团队及经验丰富的架构师高端网站策划团队;我们始终坚持从客户的角度出发,为客户量身订造网络营销方案,解决网络营销疑问。


1、加-U登录数据库

点击(此处)折叠或打开

  1. [root@master ~]# mysql -uroot -pmysql -U

  2. mysql: [Warning] Using a password on the command line interface can be insecure.

  3. Welcome to the MySQL monitor. Commands end with ; or \g.

  4. Your MySQL connection id is 12

  5. Server version: 5.7.19-log Source distribution

  6. Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

  7. Oracle is a registered trademark of Oracle Corporation and/or its

  8. affiliates. Other names may be trademarks of their respective

  9. owners.

  10. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

  11. mysql>

  12. mysql> use test;

  13. Reading table information for completion of table and column names

  14. You can turn off this feature to get a quicker startup with -A

  15. Database changed

  16. mysql> show tables;

  17. +----------------+

  18. | Tables_in_test |

  19. +----------------+

  20. | t1 |

  21. +----------------+

  22. 1 row in set (0.00 sec)

  23. mysql> show create table t1;

  24. +-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

  25. | Table | Create Table |

  26. +-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

  27. | t1 | CREATE TABLE `t1` (

  28.   `admin_id` int(11) NOT NULL DEFAULT '0',

  29.   `admin_name` varchar(200) NOT NULL,

  30.   `password` varchar(200) NOT NULL,

  31.   `role` int(11) NOT NULL DEFAULT '1',

  32.   `last_login_time` datetime DEFAULT NULL,

  33.   `last_login_ip` varchar(16) DEFAULT '',

  34.   `admin_status` int(11) NOT NULL DEFAULT '1',

  35.   `create_time` datetime DEFAULT NULL

  36. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 |

  37. +-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

  38. 1 row in set (0.00 sec)

  39. mysql> update t1 set admin_status=1234;

  40. ERROR 1175 (HY000): You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column

此处可以看到数据库给出了提示,不允许没有where条件的update操作。
2、根据这样的特性,对系统环境变量进行更改
vi /etc/profile
alias mysql='mysql -U'
source /etc/profile
3、正常命令登录MySQL,进行测试

点击(此处)折叠或打开

  1. [root@master ~]# mysql -uroot -pmysql

  2. mysql: [Warning] Using a password on the command line interface can be insecure.

  3. Welcome to the MySQL monitor. Commands end with ; or \g.

  4. Your MySQL connection id is 14

  5. Server version: 5.7.19-log Source distribution

  6. Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

  7. Oracle is a registered trademark of Oracle Corporation and/or its

  8. affiliates. Other names may be trademarks of their respective

  9. owners.

  10. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

  11. mysql> use test;

  12. Reading table information for completion of table and column names

  13. You can turn off this feature to get a quicker startup with -A

  14. Database changed

  15. mysql> update t1 set admin_status=1234;

  16. ERROR 1175 (HY000): You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column

上述内容就是MySQL中怎么防止无where条件的update操作,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注创新互联行业资讯频道。


名称栏目:MySQL中怎么防止无where条件的update操作
文章链接:http://bjjierui.cn/article/jgcshc.html

其他资讯