MySQL数据库导入导出数据之报错解答实例讲解

作者:nightelves11 时间:2024-01-24 14:56:49 

导出数据

报错


SHOW VARIABLES LIKE "secure_file_priv";
查看默认导出目录

mysql> SELECT * FROM student INTO OUTFILE "G:\ProgramData\MySQL\MySQL Server 8.0\Uploads\student.txt";
ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement

解决方法


SELECT * FROM student INTO OUTFILE "G:/ProgramData/MySQL/MySQL Server 8.0/Uploads/student.txt";
Query OK, 2 rows affected (0.02 sec)

数据展示


MySQL数据库导入导出数据之报错解答实例讲解

导入数据

报错


mysql> load data local infile 'G:/ProgramData/MySQL/MySQL Server 8.0/Uploads/student.txt'
-> into table student(a,b,c);
ERROR 3948 (42000): Loading local data is disabled; this must be enabled on both the client and server sides

解决方法


mysql> SHOW GLOBAL VARIABLES LIKE 'local_infile';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| local_infile | OFF |
+---------------+-------+
1 row in set, 1 warning (0.01 sec)

mysql> SET GLOBAL local_infile = true;
Query OK, 0 rows affected (0.00 sec)

mysql> SHOW GLOBAL VARIABLES LIKE 'local_infile';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| local_infile | ON |
+---------------+-------+
1 row in set, 1 warning (0.01 sec)

报错


mysql> load data local infile 'G:\ProgramData\MySQL\MySQL Server 8.0\Uploads\student.txt'
-> into table student(id,name,score);
ERROR 2068 (HY000): LOAD DATA LOCAL INFILE file request rejected due to restrictions on access.

解决方法


C:\Users>mysql -uroot -p --local-infile
使用这种方法登录

报错


mysql> load data local infile 'G:\ProgramData\MySQL\MySQL Server 8.0\Uploads\student.txt'
-> into table student(id,name,score);
ERROR 2 (HY000): File 'G:ProgramDataMySQLMySQL Server 8.0Uploadsstudent.txt' not found (OS errno 2 - No such file or directory)

解决方法


mysql> load data local infile 'G://ProgramData/MySQL/MySQL Server 8.0/Uploads/student.txt'
-> into table student(id,name,score);
Query OK, 8 rows affected, 2 warnings (0.01 sec)
Records: 10 Deleted: 0 Skipped: 2 Warnings: 2

结果展示


mysql> select *from student;
+------+------+-------+
| 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 |
+------+------+-------+
10 rows in set (0.00 sec)

来源:https://blog.csdn.net/qq_39528702/article/details/113954979

标签:MySQL,导入导出,报错
0
投稿

猜你喜欢

  • 结合Python的SimpleHTTPServer源码来解析socket通信

    2021-09-05 23:30:27
  • SQL Server数据库日志清除的两个方法

    2009-01-08 13:44:00
  • python匹配两个短语之间的字符实例

    2022-08-31 04:49:57
  • MySQL 使用索引扫描进行排序

    2024-01-25 09:25:15
  • python中的lambda表达式用法详解

    2022-12-01 17:33:57
  • css网页下拉菜单制作方法(2):初步实现

    2007-02-03 11:39:00
  • 基于golang的简单分布式延时队列服务的实现

    2024-05-08 10:44:03
  • PyCharm创建Django项目的简单步骤记录

    2023-08-28 11:03:37
  • Python实现获取照片的地理定位信息

    2023-06-30 01:39:54
  • php fread函数使用方法总结

    2024-05-03 15:49:24
  • javascript使用call调用微信API

    2023-07-02 05:19:48
  • Python字符串函数strip()原理及用法详解

    2021-12-01 12:08:12
  • python列表倒序的几种方法(切片、reverse()、reversed())

    2022-01-28 02:46:52
  • VsCode搭建Go语言开发环境的配置教程

    2024-05-11 09:09:02
  • Flask框架实现的前端RSA加密与后端Python解密功能详解

    2021-07-26 16:28:13
  • MySQL中随机生成固定长度字符串的方法

    2010-12-08 16:25:00
  • Go实现文件上传和下载

    2023-06-19 07:42:32
  • Python列表(list)、字典(dict)、字符串(string)基本操作小结

    2023-03-02 01:33:01
  • python实现Floyd算法

    2021-08-09 16:17:52
  • ASP四级连动下拉列表程序段

    2009-07-03 15:33:00
  • asp之家 网络编程 m.aspxhome.com