002.1使用SQL语句 MySQL 案例:备份Xq」数据库中的Xs表中的数据到D盘,要求字 段值如果是字符则用双引号标注,字段值间用逗号隔开 每行以“?”为结束标志 xstt-记xs3txt-记事本 文件日编文件(编辑(E)格式(O)查看(帮助(H 081101081101 王林”,“计算机 1990-0 2-10,50,\N,\N? 1."1991 02-01 081102 程明","计算机",1,"1991-02-01",50,N,\N? 韦严平 计算 081103 计算机",0,"1989-10-06",50,N,N? 1."198 081104","韦 王平,计算机”,1,19908-26”50,、N,1N? ","计算机 N?"081 081106 李方方","计算机",1,"1990-11-20",50,\N,N? 机1,“08108"林二帆"计算机”,1,19890805,50,NN, N?081081109","张强民","计算机",1,"1989-08-11",50,N,N? 081110″,"张巍","计算机",0,"1991-07-22",50,N,N? 08111,赵琳”,“计算机",0,"1990-03-18",50,\N,N? 081113","严红","计算机",1,"1989-08-11",50,N,\N? 081201","王敏","通信工程",1,"1989-06-10",42,N,N? 081202","王林",“"通信工程",1,"1989-01-29″,40,\N,N? (( 第16页
《MySQL数据库应用》 http://mysql.xg.hactcm.edu.cn/ 第 16 页 2.1 使用SQL语句 • 案例:备份xscj数据库中的xs表中的数据到D盘,要求字 段值如果是字符则用双引号标注,字段值间用逗号隔开, 每行以“?”为结束标志
002.1使用SQL语句 MySQL 案例1:备份Xsq数据库中的Xs表中的数据到D盘,要求字 段值如果是字符则用双引号标注,字段值间用逗号隔开 每行以“?”为结束标志 实现语句1: use XscJ; select *k from xs into outfile 'D:/xs.txt l lds terminated by opt ional ly enc losed by i nes terminated by? MySQL数据库应用》http:/mysq!xg.hactcm.edu.cn 第17页
《MySQL数据库应用》 http://mysql.xg.hactcm.edu.cn/ 第 17 页 2.1 使用SQL语句 • 案例1:备份xscj数据库中的xs表中的数据到D盘,要求字 段值如果是字符则用双引号标注,字段值间用逗号隔开, 每行以“?”为结束标志。 • 实现语句1: use xscj; select * from xs into outfile 'D:/xs.txt' fields terminated by ' , ' optionally enclosed by '"' lines terminated by '?' ;
002.1使用SQL语句 MySQL mysql> se lect eesecure-file_priv; eesecure file_priv i C: \ProgramData MySQL Server 5.7Nploads\ H row in set (0.03 sec) 说明: 在使用 SELECT NTO0…· OUTFILE语句时,指定的目标路径只能是 MySQL的 secure_ file prⅳ参数指定的位置,否则就产生上图错误。 该位置可以通过在MyS呲L的命令行窗口中,输入以下语句获得: select @@secure file priv; MySQL数据库应用》http:/mysq!xg.hactcm.edu.cn 第18页
《MySQL数据库应用》 http://mysql.xg.hactcm.edu.cn/ 第 18 页 2.1 使用SQL语句 说明: 在使用SELECT INTO … OUTFILE语句时,指定的目标路径只能是 MySQL的secure_file_priv参数指定的位置,否则就产生上图错误。 该位置可以通过在MySQL的命令行窗口中,输入以下语句获得: select @@secure_file_priv;
002.1使用SQL语句 MySQL myInt记事本 ‖文件(一编辑()格式(O)查看(帮助(H slow-query-l0g=1 slow query log file="USER-PC-slow. log 据 long query time=10 Binary logging log-bin Error logging log-error="USER-PC err secure file pr iv="d: Server Id server-id=1 Secure File priv secure-file-priv"C: /ProgramData/ My SQL/MySQL Server 5. 6/Uploads t The maximum amount of concurrent sessions the My SQL server will allow. One of these connections will be reserved for a user wi th SUPER privileges to allow the administrator to login even if the connection limit has been reached max connections=151 MySQL数据库应用》http:/mysq!xg.hactcm.edu.cn 第19页
《MySQL数据库应用》 http://mysql.xg.hactcm.edu.cn/ 第 19 页 2.1 使用SQL语句 • MySQL的secure_file_priv参数指定的位置可以修改: Windows下,打开my.ini文件,可以修改加载路径及数据 位置。 (1) mysql5.6以下版本: my.ini文件在c:\Program Files\MySQL下 (2) mysql5.7以上版本: my.ini文件在c:\ProgramData\MySQL下 secure_file_priv=“d:/
002.1使用SQL语句 MySQL 实现语句2: use XscJ; select *k from xs into outfile c:/programdata/mysq l/mysql server 5. 7/up loads/xs. txt fields terminated by opt ional ly enc losed by l ines terminated b y'2 MySQL数据库应用》http:/mysq!xg.hactcm.edu.cn 第20页
《MySQL数据库应用》 http://mysql.xg.hactcm.edu.cn/ 第 20 页 2.1 使用SQL语句 • 实现语句2: use xscj; select * from xs into outfile 'c:/programdata/mysql/mysql server 5.7/uploads/xs.txt' fields terminated by ' , ' optionally enclosed by '"' lines terminated by '?' ;