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