In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
In practical application, we must encounter the need to export the data in the database. Below, I will summarize my own experience accordingly. I am afraid that I will forget for a long time. I hope I can record it so that I can make a follow-up inquiry. At the same time, I also hope to help those in need.
Some actions need to be taken when a table in the MySQL database needs to be directed
1. First go to your mysql database to execute instructions
For example:
Method 1:
After the query and other actions, the tables in the database will display the query results.
Because my external database is installed in the docker of 172.16.22.7, I have to go into the docker to execute the operation statements. Of course, if you install the MySQL client outside the docker, you can directly carry out the corresponding operation in the machine.
First go to 172.16.22.7 and then execute the following sentences
1.docker exec-it compassionate_sinoussi bash
# the above compassionate_sinoussi is my container name
2.mysql-u t-p erico998 zgz
# enter my database, parameter description:-u user name-p user password database name
Execute query instructions later (where outfile is to send data to the specified path)
3.mysql [zgz] > select a.f_info_id as info_id, a.f_diggs as info_diggs
A.f_reprints as info_reprints,b.f_diggs as buffer_diggs
B.f_reprints as buffer_reprints from cms_info a
Cms_info_buffer b where a.f_info_id = b.f_info_id
Order by info_id asc into outfile'/ tmp/aa.txt'
It is found that / tmp/aa.txt does not exist after query and needs to be found
4.find /-name aa.txt
It is found that aa.txt is in the embedded file of tmp, so in the follow-up operation, we need to add a path and directly fill in the file name to generate it in tmp.
Next, we will examine how to transfer the internal data of the container to the 172.16.22.7 host.
5.docker cp container_id:/a.txt / a.txt
If you need to transfer files remotely to another machine, such as from 172.16.22.7 to 172.16.2.1, follow the following statement:
6.scp aa.txt root@172.16.22.1:/data0/
Through the above actions, you can count the query results needed by the database and put them into the hands of people who need this data.
Method 2:
The database data is exported to excel format:
You can use the "line" sentence directly in 172.16.22.7.
Echo "use database name; sql sentence to be operated" | mysql-h container IP-u user-p user password > path and name for storing data
Such as: echo "use zgz; select a.f_info_id as info_id, a.f_diggs as info_diggs
A.f_reprints as info_reprints,b.f_diggs as buffer_diggs
B.f_reprints as buffer_reprints from cms_info a
Cms_info_buffer b where a.f_info_id = b.f_info_id
Order by info_id asc "| mysql-h 172.17.0.1-ut-perico998 > / data0/test.xls
Similarly, files are transferred remotely between servers, such as from 172.16.22.7 to 172.16.22.1
Scp test.txt root@172.16.22.1:/data0/
However, because my mysql is directly derived from the utf8 format, the code will appear when the excel is opened. If you send excel directly back to your own office computer, open it with notepad, and then copy and paste the data to the new excel table.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.