[root@db01 ~]# mysql --help | grep "\-U"
-U, --safe-updates Only allow UPDATE and DELETE that uses keys.
-U, --i-am-a-dummy Synonym for option --safe-updates, -U.
说明:在mysql命令加上选项-U后,当执行UPDATE或DELETE时,没有WHERE或LIMIT关键字的时候,mysql程序就会拒绝执行
例如:执行以下内容时 拒绝执行
mysql -uroot -p -S /data/3306/mysql.sock -U
mysql> update test set name='soul';
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 -U制作成别名,永久生效需要追加到/etc/profile文件中
[root@db01 ~]#alias mysql="mysql -U"
此时登录mysql,不加-U,依然会有安全提示
[root@db01 ~]# mysql -uroot -p -S /data/3306/mysql.sock
mysql> update test set name='soul';ERROR 1175 (HY000): You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column
注:此方法只有在本地登录时才起作用
最后更新于 2020-05-30 09:09:39 并被添加「mysql」标签,已有 18 位童鞋阅读过。
本站使用「署名 4.0 国际」创作共享协议,可自由转载、引用,但需署名作者且注明文章出处
相关文章