显示数据库/表INTO OUTFILE [英] Show Databases/Tables INTO OUTFILE
问题描述
是否有一种方法来获取SHOW DATABASES
或SHOW TABLES
命令的输出以输出到文本文件,类似于SELECT ... INTO OUTFILE
的工作方式?
Is there a way of getting the output of a SHOW DATABASES
or SHOW TABLES
command to output to a text file, similar to how the SELECT ... INTO OUTFILE
works?
INTO OUTFILE
在SHOW
命令上使用时会产生语法错误.如果有办法使用mysqldump之类的cmdline工具来生成此命令,我可以使用外部命令.
The INTO OUTFILE
produces a syntax error when used on a SHOW
command. I am open to external commands if there is a way to produce this using a cmdline tool such as mysqldump.
推荐答案
最好的输出方法是将数据通过管道传输到文件中.例如:
The best way to output this would be to pipe the data to a file. For instance:
mysql -u root -e "SHOW DATABASES" > my_outfile.txt
@Velko的答案是一个很好的答案,但前提是您可以访问服务器文件系统.如果服务器与客户端位于不同的系统上,则管道传输是在本地客户端系统上获取文件的唯一方法.
@Velko's answer is a good answer but only if you can access the server file system. If the server is on a different system than the client, piping will be the only way to get the file on the local client system.
这篇关于显示数据库/表INTO OUTFILE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!