[root@localhost ~]# mysql -uroot -p ##进入MySQL
mysql> use school; ##进库
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with-A
Database changed
mysql> select *from 乘法表; ##查看表信息
+----------------------------------------------------------------------------------+| 九九 |+----------------------------------------------------------------------------------+|1*1=1||2*1=22*2=4||3*1=
33*2=63*3=9||4*1=44*2=84*3=124*4=16||5*1=55*2=105*3=155*4=205*5=25||6*1=66*2=126*3=186*4=246*5=306*6=36||7*1=77*2=147*3=217*4=287*5=357*6=427*7=49||8*1=88*2=168*3=248*4=328*5=408*6=488*7=568*8=64||9*1=99*2=189*3=279*4=369*5=459*6=549*7=639*8=729*9=81|+----------------------------------------------------------------------------------+9 rows inset(0.00 sec)
mysql> select *from 乘法表 into outfile '/opt/share/乘法表.xls'; ##使用这条SQL语句将表导出为xls格式文件
Query OK,9 rows affected(0.01 sec)
mysql> \q ##退出数据库
Bye
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
4.查看目录中标是否已经导出成功
[root@localhost ~]# cd /opt/share/ ##进入到存放表的目录,查看是否出现导出的表
[root@localhost share]# ll
total 12-rw-rw-rw-1 mysql mysql 401 Oct 1914:26 乘法表.xls
[root@localhost share]# cat 乘法表.xls ##导出成功
1*1=12*1=22*2=43*1=33*2=63*3=94*1=44*2=84*3=124*4=165*1=55*2=105*3=155*4=205*5=256*1=66*2=126*3=186*4=246*5=306*6=367*1=77*2=147*3=217*4=287*5=357*6=427*7=498*1=88*2=168*3=248*4=328*5=408*6=488*7=568*8=649*1=99*2=189*3=279*4=369*5=459*6=549*7=639*8=729*9=81
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
5.将xls文件拉取到Windows系统中
直接将Linux系统中文件复制到Windows中查看
方法二:只有数据,无表结构
[root@localhost ~]# mysql -uroot -p school -e "select * from 乘法表;">/opt/九九.xls
Enter password:[root@localhost ~]# cat /opt/九九.xls
九九
12436948121651015202561218243036714212835424981624324048566491827364554637281