IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    MySQL:导出Excel

    Adamhuan发表于 2016-09-21 06:30:04
    love 0

    数据库端导出:

    [root@linuxme ~]# mysql -uroot -p
    Enter password: 
    Welcome to the MariaDB monitor.  Commands end with ; or \g.
    Your MariaDB connection id is 53792
    Server version: 10.1.16-MariaDB-enterprise MariaDB Enterprise Certified Binary
    
    Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
    
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    
    MariaDB [(none)]> use adamhuan;
    Database changed
    MariaDB [adamhuan]> select * from people;
    +----+------------+------+----------+---------+
    | id | name       | age  | location | other   |
    +----+------------+------+----------+---------+
    |  1 | tim_tian   |   34 | shanghai | Monitor |
    |  2 | eric_huang |   89 | shanghai | PM      |
    |  3 | Neo_Guo    |   73 | shanghai | CUST    |
    |  4 | Henry_Cai  |   24 | shanghai | coding  |
    +----+------------+------+----------+---------+
    4 rows in set (0.00 sec)
    
    MariaDB [adamhuan]> 
    MariaDB [adamhuan]> select * from people into outfile '/tmp/mysql_output_adamhuan_people.xls';
    Query OK, 4 rows affected (0.03 sec)
    
    MariaDB [adamhuan]> exit
    Bye
    [root@linuxme ~]# ls -ltr --time-style="+|%Y-%m-%d|%H:%M:%S|" /tmp | grep --color mysql_output
    -rw-rw-rw-  1 mysql  mysql      117 |2016-09-21|14:24:20| mysql_output_adamhuan_people.xls
    [root@linuxme ~]#

    然后,把导出文件拉到本地,并打开:
    mysql_output_1

    mysql_output_2

    这样,就结束了。
    ————————————————————————
    2016年9月21日14:29:49



沪ICP备19023445号-2号
友情链接