Show Databases/Tables INTO OUTFILE

≯℡__Kan透↙ 提交于 2019-11-30 21:22:48

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'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.

You can try this:

SELECT TABLE_SCHEMA INTO OUTFILE '/tmp/stack.txt' FROM information_schema.TABLES GROUP BY TABLE_SCHEMA

Another Example:

SET @databasesInfo := '';
SHOW DATABASES WHERE (@databasesInfo := CONCAT(@databasesInfo, `Database`, ','));
SELECT @databasesInfo INTO OUTFILE '/tmp/so2.txt';
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!