荣耀彩票代理

IT技术互动交流平台

使用SELECT INTO OUTFILE进行导出mysql数据库的数据的教程

发布日期:2018-12-10 10:47:07

导出mysql数据库教程

荣耀彩票代理  YIXIASHILIZHONGZANMENJIANGSHUJUBIAO runoob_tbl SHUJUDAOCHUDAO /tmp/runoob.txt WENJIANZHONG:

荣耀彩票代理  mysql> SELECT * FROM runoob_tbl

  -> INTO OUTFILE '/tmp/runoob.txt';

  NINENGGOUJINGGUOZHILINGXUANXIANGLAISHEZHISHUJUSHUCHUDEZHIDINGGEJU,YIXIASHILIWEIDAOCHU CSV GEJU:

  mysql> SELECT * FROM passwd INTO OUTFILE '/tmp/runoob.txt'

  -> FIELDS TERMINATED BY ',' ENCLOSED BY '"'

  -> LINES TERMINATED BY '\r\n';

  BIRENMIANDEBIRUZHONG,SHENGCHENGYIGEWENJIAN,GEZHIYONGDOUHAOLIGE。ZHEIZHONGGEJUNENGGOUBEIXUDUOCHENGXUYUNYONG。

  SELECT a,b,a+b INTO OUTFILE '/tmp/result.text'

  FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'

荣耀彩票代理  LINES TERMINATED BY '\n'

荣耀彩票代理  FROM test_table;

  SELECT ... INTO OUTFILE JUZIYOUYIXIATEDIAN:

荣耀彩票代理  LOAD DATA INFILESHISELECT ... INTO OUTFILEDENICAOZUO,SELECTJUFA。WEILEJIANGYIGESHUJUKUDESHUJUXIERUYIGEWENJIAN,YUNYONGSELECT ... INTO OUTFILE,WEILEJIANGWENJIANDUHUISHUJUKU,YUNYONGLOAD DATA INFILE。

  SELECT...INTO OUTFILE 'file_name'FANGSHIDESELECTNENGGOUBABEITIAOXUANDEXINGXIERUYIGEWENJIANZHONG。GAIWENJIANBEICHUANGLIDAOFUWUQIZHUJISHANG,YINERNINYOUBIYAOJUYOUFILEQUANXIAN,CAIGANYUNYONGCIYUFA。

荣耀彩票代理  SHUCHUBUNENGSHIYIGEYICUNZAIDEWENJIAN。BIMIANWENJIANSHUJUBEICUANGAI。

  NIXUQIUYOUYIGEDENGLUFUWUQIDEZHANGHAOLAIJIANSUOWENJIAN。BURAN SELECT ... INTO OUTFILE BUHUIQIRENHEXIAOGUO。

  在UNIX中,该文件被创立后是可读的,权限由MySQL荣耀彩票代理服务器所具有。这意味着,尽管你就能够读取该文件,但或许无法将其删去。

  DAOCHUBIAOZUOWEIYUANSHISHUJU

  mysqldump SHI mysql YONGYUZHUANCUNCHUSHUJUKUDESHIYONGCHENGXU。TASHOUYAOFASHENGYIGE SQL JIAOBEN,QIJIANBAOKUOCONGTOUCONGTOUCHUANGLISHUJUKUSUOBIXUDEZHILING CREATE TABLE INSERT DENG。

  YUNYONG mysqldump DAOCHUSHUJUXUQIUYUNYONG --tab XUANXIANGLAIZHIDINGDAOCHUWENJIANZHIDINGDEMULU,GAIFANGZHENYOUBIYAOSHIKEXIEDE。

  YIXIASHILIJIANGSHUJUBIAO runoob_tbl DAOCHUDAO /tmp MULUZHONG:

  $ mysqldump -u root -p --no-create-info \

荣耀彩票代理  --tab=/tmp RUNOOB runoob_tbl

  password ******

  DAOCHU SQL GEJUDESHUJU

  DAOCHU SQL GEJUDESHUJUDAOZHIDINGWENJIAN,RUXIASUOSHI:

  $ mysqldump -u root -p RUNOOB runoob_tbl > dump.txt

  password ******

荣耀彩票代理  YISHANGZHILINGCHUANGLIDEWENJIANNEIRONGRUXIA:

  -- MySQL dump 8.23

  --

  -- Host: localhost Database: RUNOOB

  ---------------------------------------------------------

荣耀彩票代理  -- Server version 3.23.58

  --

  -- Table structure for table `runoob_tbl`

  --

荣耀彩票代理  CREATE TABLE runoob_tbl (

  runoob_id int(11) NOT NULL auto_increment,

  runoob_title varchar(100) NOT NULL default '',

  runoob_author varchar(40) NOT NULL default '',

荣耀彩票代理  submission_date date default NULL,

  PRIMARY KEY (runoob_id),

荣耀彩票代理  UNIQUE KEY AUTHOR_INDEX (runoob_author)

  ) TYPE=MyISAM;

  --

荣耀彩票代理  -- Dumping data for table `runoob_tbl`

  --

荣耀彩票代理  INSERT INTO runoob_tbl

  VALUES (1,'Learn PHP','John Poul','2007-05-24');

  INSERT INTO runoob_tbl

荣耀彩票代理  VALUES (2,'Learn MySQL','Abdul S','2007-05-24');

荣耀彩票代理  INSERT INTO runoob_tbl

  VALUES (3,'JAVA Tutorial','Sanjay','2007-05-06');

荣耀彩票代理  JIARUNIXUQIUDAOCHUZHENGGESHUJUKUDESHUJU,NENGGOUYUNYONGYIXIAZHILING:

荣耀彩票代理  $ mysqldump -u root -p RUNOOB > database_dump.txt

  password ******

  JIARUXUQIUBEIFENYIQIESHUJUKU,NENGGOUYUNYONGYIXIAZHILING:

  $ mysqldump -u root -p --all-databases > database_dump.txt

  password ******

  --all-databases XUANXIANGZAI MySQL 3.23.12 JIJINHOUBANBIECANJIA。

  GAIBANFAKEYONGYUWANCHENGSHUJUKUDEBEIFENZHANLVE。

  JIANGSHUJUBIAOJISHUJUKUFUZHIZHIQITAZHUJI

  JIARUNIXUQIUJIANGSHUJUFUZHIZHIQITADE MySQL FUWUQISHANG, NINENGGOUZAI mysqldump ZHILINGZHONGZHIDINGSHUJUKUMINGJISHUJUBIAO。

  ZAIYUANZHUJISHANGLVXINGYIXIAZHILING,JIANGSHUJUBEIFENZHI dump.txt WENJIANZHONG:

荣耀彩票代理  $ mysqldump -u root -p database_name table_name > dump.txt

  password *****

  JIARUWANHAOBEIFENSHUJUKU,ZEWUXUYUNYONGTEDINGDEBIAOCHENGHAO。

荣耀彩票代理  JIARUNIXUQIUJIANGBEIFENDESHUJUKUDAORUDAOMySQLFUWUQIZHONG,NENGGOUYUNYONGYIXIAZHILING,YUNYONGYIXIAZHILINGNIXUQIUCHENGRENSHUJUKUXIANYICHUANGLI:

荣耀彩票代理  $ mysql -u root -p database_name < dump.txt

  password *****

荣耀彩票代理  NIYENENGGOUYUNYONGYIXIAZHILINGJIANGDAOCHUDESHUJUZHIJIEDAORUDAOZHANGTUDEFUWUQISHANG,DANQINGBAOZHENGLIANGTAIFUWUQISHIXIANGTONGDE,SHINENGGOUBICIBAIFANGDE:

  $ mysqldump -u root -p database_name \

  | mysql -h other-host.com database_name

  YISHANGZHILINGZHONGYUNYONGLEGUANDAOLAIJIANGDAOCHUDESHUJUDAORUDAOZHIDINGDEZHANGTUZHUJISHANG。

延伸阅读:

Tag标签:         
  • 专题推荐

About IT165 - 广告服务 - 隐私声明 - 版权申明 - 免责条款 - 网站地图 - 网友投稿 - 联系方式
本站内容来自于互联网,仅供用于网络技术学习,学习中请遵循相关法律法规