背景:使用云服务器的时候,没有ui界面,有些东西看的不太方便,所以需要导出来查看
方法:
1.通过sftp连接到服务器
sftp root@47.xx.x.xxx
2.ls 找到对应的文件
sftp> cd logs
sftp> ls
alinode clean
master-stderr.log master-stderr.log.20190603.171422
master-stdout.log master-stdout.log.20190603.171422
3.通过get将文件导出
sftp> get master-stderr.log
Fetching /root/logs/master-stderr.log to master-stderr.log
4.也可以通过put将电脑中的文件导入
下面说一下具体的例子:
将数据库取出一列导出到电脑中
步骤一:将数据库中的内容导出到文件中
mysql -uxxx -pxxx device -e "select imei from info into outfile'/var/lib/mysql-files/out2.sql'"
路径需要指定否则会报如下错误:
[root@xxx controller]# mysql -uxxx -pxxx device -e "select * from info into outfile'out.sql'"
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1290 (HY000) at line 1: The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
步骤二:查看我们生成的文件:
imeixxxxxxxx
860113044803534
860113044803534
步骤三:按照我们上面说的导出