疑问?mysql -uroot -proot -hlocalhost -D school -e "select * from student;" -B -N

来源:11-2 Shell脚本与MySQL数据库交互(增删改查)

八卦一百二十八掌

2021-01-27

老师课程中讲-B需要写到-N的后面,-e的前面,不然查询不出来结果。
经过测试:
[root@shell~]# mysql -uroot -proot -hlocalhost -D school -e “select * from student;” -B -N
[root@shell ~]# mysql -uroot -proot -hlocalhost -D school -B -N -e “select * from student;”
[root@shell ~]# mysql -uroot -proot -hlocalhost -D school -N -B -e "select * from student;"
这几种写法都可以查询出来结果。

[root@shell ~]# mysql -uroot -proot -hlocalhost -D school -e "select * from student;" -B -N
mysql: [Warning] Using a password on the command line interface can be insecure.
1001	zhaolei	1990-1001-1001	male
1002	lihang	1990-12-21	male
1003	yanwen	1990-1005-20	male
1004	hongfei	1990-1008-1006	male
1005	ligang	1991-12-1001	female
1006	zhousheng	1992-1003-1001	female
1007	wangjun	1989-1007-1001	female
1008	zhoufei	1990-1001-20	female

这几个参数应该不讲求顺序,不知道这样理解是不是对的。

写回答

1回答

酷田

2021-02-28

从您反馈的结果来看的确是的,不按照顺序也是可以的。我再课程中使用的mysql客户端版本可能有这个限制,这个也是当时做课程测试出来的。如果您的没有顺序也可以,那就没问题。

0
0

掌握Shell脚本编程 360架构师带你进阶Linux高手

30%知识讲解+70%实例操作 掌握Shell脚本编程能力

1638 学习 · 297 问题

查看课程