mysql使用脚本将列名、类型、备注等以excel格式导出

1、导出表为excel所用的命令

        mysql> select * from user  into outfile "f:/data/user.xls";

        报错:ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv opti

        on so it cannot execute this statement

        因为在安装MySQL的时候限制了导入与导出的目录权限

        解决办法:找到允许导出的目录,

        mysql> show variables like '%secure%';

        +--------------------------+------------------------------------------------+

        | Variable_name            | Value                                          |
        +--------------------------+------------------------------------------------+
        | require_secure_transport | OFF                                            |
        | secure_auth              | ON                                             |
        | secure_file_priv         | C:\ProgramData\MySQL\MySQL Server 5.7\Uploads\ |
        +--------------------------+------------------------------------------------+

        选择最后一行的结果作为导出路径;

2、导出某个表中的列名,类型及备注:

http://www.netingcn.com/mysql-column-name.html

mysql> select column_name,COLUMN_type,column_default from information_schema.COL

UMNS where table_name = 'user' into outfile "C:/ProgramData/MySQL/MySQL Server 5

.7/Uploads/user.xls";


你可能感兴趣的:(mysql)