In addition to Weibo, there is also WeChat
Please pay attention

WeChat public account
Shulou
2025-10-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how the terminal should use mysql to execute sql statements, the contents of the articles are carefully selected and edited by the author, with a certain pertinence, the reference significance for everyone is still relatively great, the following with the author to understand how the terminal should use mysql to execute sql statements.
Mysql-urootmysql > use mydb;mysql > select * from user;...
If we need to monitor some tables and save the query results after execution, we need to copy them to a file manually, which affects productivity.
Terminal executes sql
Therefore, the following method is provided, which can directly use shell to call mysql to execute sql statement on the terminal without entering mysql.
Mysql provides the-e parameter to execute the statement directly on the terminal and output it.
For example:
Mysql-uroot-e'select * from mydb.user'
When you use mysql-e to execute a statement, you can add-v,-vv,-vvv parameters
-v displays the statement itself
-vv increases the number of rows displaying query results
-vvv increases display execution time
The execution result is written to the file
Using output redirection, you can save the results of the execution to a file.
For example:
Mysql-uroot-e'select * from mydb.user' > / tmp/mydb_user.txt
After the terminal executes, the query results are saved to / tmp/mydb_user.txt.
After reading the above about how the terminal should use mysql to execute sql statements, many readers must have some understanding. If you need to get more industry knowledge and information, you can continue to follow our industry information column.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope





About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.