MySQL使用shell命令执行sql

mysql -u${用户名} -p -e"SQL语句"; # 确认之后输入密码即可

下面举个例子:

[root@ecs-s3-large-2-linux-20200627183241 ~]# mysql -uzhoujl -p -e"show processlist";
Enter password: 
+----+--------+-----------+------+---------+------+----------+------------------+
| Id | User   | Host      | db   | Command | Time | State    | Info             |
+----+--------+-----------+------+---------+------+----------+------------------+
| 20 | zhoujl | localhost | NULL | Query   |    0 | starting | show processlist |
+----+--------+-----------+------+---------+------+----------+------------------+
[root@ecs-s3-large-2-linux-20200627183241 ~]# 
posted @ 2020-12-29 15:40  周建林  阅读(650)  评论(0编辑  收藏  举报