1,输出数据库版本变量为xml格式
Shell> mysql -X -uroot -proot -e "use test; show variables like '%version%';"
参数X表示生成xml格式的输出 , 参数e表示执行后面的命令
protocol_version
10
version
5.0.22-community-nt-log
version_comment
MySQL Community Edition (GPL)
version_compile_machine
ia32
version_compile_os
Win32
2,导出表数据到xml文件
Shell> mysql -X -uroot -proot -e "use test; select * from test;" > ./a.xml
Shell> more a.xml
111
10
1
110
3,换一种方式导出表结构和内容,其中第一个db_name是数据库名,第二个test是表名
Shell> mysqldump --xml -uroot -proot db_name test
<options name="test" engine="InnoDB" version="10" row_format="Compact" rows="4" avg_row_length="4096" data_length="16384" max_data_length="0" index_length="0" data_free="0" create_time=""
="2008-09-04 02:45:12" Collation="utf8_general_ci" Create_options="" Comment="InnoDB free: 11264 kB" />
111
10
1
110
4,导入xml文件的内容到数据库表,这里主要用到了load_file()函数
mysql> create table xmlt(
-> id int ,
-> doc blob
-> );
mysql> insert into xmlt values(1,load_file('/home/a.xml') );
mysql> select * from xmlt;
+------+--------------------------------------
----------------------------------------------
| id | doc
+------+--------------------------------------
----------------------------------------------
| 1 |
111
10
1
110
Shell> mysql -X -uroot -proot -e "use test; show variables like '%version%';"
参数X表示生成xml格式的输出 , 参数e表示执行后面的命令
protocol_version
10
version
5.0.22-community-nt-log
version_comment
MySQL Community Edition (GPL)
version_compile_machine
ia32
version_compile_os
Win32
2,导出表数据到xml文件
Shell> mysql -X -uroot -proot -e "use test; select * from test;" > ./a.xml
Shell> more a.xml
111
10
1
110
3,换一种方式导出表结构和内容,其中第一个db_name是数据库名,第二个test是表名
Shell> mysqldump --xml -uroot -proot db_name test
<options name="test" engine="InnoDB" version="10" row_format="Compact" rows="4" avg_row_length="4096" data_length="16384" max_data_length="0" index_length="0" data_free="0" create_time=""
="2008-09-04 02:45:12" Collation="utf8_general_ci" Create_options="" Comment="InnoDB free: 11264 kB" />
111
10
1
110
4,导入xml文件的内容到数据库表,这里主要用到了load_file()函数
mysql> create table xmlt(
-> id int ,
-> doc blob
-> );
mysql> insert into xmlt values(1,load_file('/home/a.xml') );
mysql> select * from xmlt;
+------+--------------------------------------
----------------------------------------------
| id | doc
+------+--------------------------------------
----------------------------------------------
| 1 |
111
10
1
110