MySQL数据库导入导出数据之报错解答实例讲解
导出数据
报错
SHOWVARIABLESLIKE"secure_file_priv"; 查看默认导出目录
mysql>SELECT*FROMstudentINTOOUTFILE"G:\ProgramData\MySQL\MySQLServer8.0\Uploads\student.txt"; ERROR1290(HY000):TheMySQLserverisrunningwiththe--secure-file-privoptionsoitcannotexecutethisstatement
解决方法
SELECT*FROMstudentINTOOUTFILE"G:/ProgramData/MySQL/MySQLServer8.0/Uploads/student.txt"; QueryOK,2rowsaffected(0.02sec)
导入数据
报错
mysql>loaddatalocalinfile'G:/ProgramData/MySQL/MySQLServer8.0/Uploads/student.txt' ->intotablestudent(a,b,c); ERROR3948(42000):Loadinglocaldataisdisabled;thismustbeenabledonboththeclientandserversides
解决方法
mysql>SHOWGLOBALVARIABLESLIKE'local_infile'; +---------------+-------+ |Variable_name|Value| +---------------+-------+ |local_infile|OFF| +---------------+-------+ 1rowinset,1warning(0.01sec) mysql>SETGLOBALlocal_infile=true; QueryOK,0rowsaffected(0.00sec) mysql>SHOWGLOBALVARIABLESLIKE'local_infile'; +---------------+-------+ |Variable_name|Value| +---------------+-------+ |local_infile|ON| +---------------+-------+ 1rowinset,1warning(0.01sec)
报错
mysql>loaddatalocalinfile'G:\ProgramData\MySQL\MySQLServer8.0\Uploads\student.txt' ->intotablestudent(id,name,score); ERROR2068(HY000):LOADDATALOCALINFILEfilerequestrejectedduetorestrictionsonaccess.
解决方法
C:\Users>mysql-uroot-p--local-infile 使用这种方法登录
报错
mysql>loaddatalocalinfile'G:\ProgramData\MySQL\MySQLServer8.0\Uploads\student.txt' ->intotablestudent(id,name,score); ERROR2(HY000):File'G:ProgramDataMySQLMySQLServer8.0Uploadsstudent.txt'notfound(OSerrno2-Nosuchfileordirectory)
解决方法
mysql>loaddatalocalinfile'G://ProgramData/MySQL/MySQLServer8.0/Uploads/student.txt' ->intotablestudent(id,name,score); QueryOK,8rowsaffected,2warnings(0.01sec) Records:10Deleted:0Skipped:2Warnings:2
结果展示
mysql>select*fromstudent; +------+------+-------+ |id|name|score| +------+------+-------+ |1|zs|100.0| |2|zlh|100.0| |3|cyx|99.1| |4|xjj|90.0| |5|aa|100.0| |6|alk|20.1| |7|zml|11.1| |8|djh|98.0| |9|cc|100.0| |10|pp|20.0| +------+------+-------+ 10rowsinset(0.00sec)
到此这篇关于MySQL数据库导入导出数据之报错解答实例讲解的文章就介绍到这了,更多相关MySQL数据库导入导出数据之报错解答内容请搜索毛票票以前的文章或继续浏览下面的相关文章希望大家以后多多支持毛票票!
声明:本文内容来源于网络,版权归原作者所有,内容由互联网用户自发贡献自行上传,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任。如果您发现有涉嫌版权的内容,欢迎发送邮件至:czq8825#qq.com(发邮件时,请将#更换为@)进行举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。