在这篇文章中,我们将带领您了解MySQL导入csv文件报错[ErrorCode]1290-TheMySQLserverisrunningwiththe--secure-file-privoption解
在这篇文章中,我们将带领您了解MySQL 导入 csv 文件报错 [Error Code] 1290 - The MySQL server is running with the --secure-file-priv option 解决办法的全貌,同时,我们还将为您介绍有关1209 -The MySQL server is running with the --read-only option、Centos6 下 Mysql启动提示 Starting MySQL. ERROR! The server quit without updating PID file、ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cann...、ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot e...的知识,以帮助您更好地理解这个主题。
本文目录一览:- MySQL 导入 csv 文件报错 [Error Code] 1290 - The MySQL server is running with the --secure-file-priv option 解决办法
- 1209 -The MySQL server is running with the --read-only option
- Centos6 下 Mysql启动提示 Starting MySQL. ERROR! The server quit without updating PID file
- ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cann...
- ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot e...
MySQL 导入 csv 文件报错 [Error Code] 1290 - The MySQL server is running with the --secure-file-priv option 解决办法
错误:[Error Code] 1290 - The MySQL server is running with the --secure-file-priv option
mysql>show variables like ''%secure%'';;
secure_file_prive=null -- 限制mysqld 不允许导入导出
secure_file_priv=/tmp/ -- 限制mysqld的导入导出只能发生在/tmp/目录下
secure_file_priv='' '' -- 不对mysqld 的导入 导出做限制
解决方法:
打开 my.ini 文件: 在文件中添加: secure-file-priv="D:/jb"
1. 将 test.csv 文件导入 mysql 中
load data infile ''D:/jb/a.csv'' -- CSV文件存放路径
into table test -- 要将数据导入的表名
fields terminated by '','' optionally enclosed by ''"'' escaped by ''"'' -- 字段之间以逗号分隔,字符串以半角双引号包围,字符串本身的双引号用两个双引号表示
lines terminated by ''\r\n''; -- 数据行之间以\r\n分隔
执行成功效果如下:
2 将 tes.csv 文件导入 mysql (包含中文)
a. 用 文本编辑器 打开 CSV 文件 另存为 utf8 格式 ,再导入
load data infile ''D:/jb/a.csv'' -- CSV文件存放路径
into table test character set ''utf8'' -- 要将数据导入的表名 设置编码
fields terminated by '','' optionally enclosed by ''"'' escaped by ''"'' -- 字段之间以逗号分隔,字符串以半角双引号包围,字符串本身的双引号用两个双引号表示
lines terminated by ''\r\n''; -- 数据行之间以\r\n分隔
3. 将库中的数据导出 CSV 文件(包括中文)
select * from test
into outfile ''D:/jb/b.csv'' character set ''gbk''
FIELDS TERMINATED BY '',''
OPTIONALLY ENCLOSED BY ''"''
LINES TERMINATED BY ''\r\n'';
执行结果如下:
1209 -The MySQL server is running with the --read-only option
1209 - The MySQL server is running with the --read-only option so it cannot execute this statement
一般这个错误有两种原因:
1.连到从库了。从库一般设置为只读。
2.主库的read_only参数被修改为1
解决办法:set global read_only=0;
https://blog.csdn.net/lwei_998/article/details/50445830
https://stackoverflow.com/questions/35445190/strange-mysql-read-only-error
文章来源:刘俊涛的博客
欢迎关注,有问题一起学习欢迎留言、评论
每一个你不满意的现在,都有一个你没有努力的曾经。
Centos6 下 Mysql启动提示 Starting MySQL. ERROR! The server quit without updating PID file
环境说明
问题描述
[root@LNMP ~]# /etc/init.d/MysqL start Starting MysqL. ERROR! The server quit without updating PID file (/usr/local/MysqL/var/LNMP.pid).
root@LNMP var]# tail -f /usr/local/MysqL/var/LNMP.err /usr/local/MysqL/bin/MysqLd: Can't create/write to file '/tmp/ibJb9vcs' (Errcode: 13) 161201 8:45:41 InnoDB: Error: unable to create temporary file; errno: 13 161201 8:45:41 [ERROR] Plugin 'InnoDB' init function returned error. 161201 8:45:41 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE Failed. 161201 8:45:41 [ERROR] UnkNown/unsupported storage engine: InnoDB 161201 8:45:41 [ERROR] Aborting 161201 8:45:41 [Note] /usr/local/MysqL/bin/MysqLd: Shutdown complete 161201 08:45:41 MysqLd_safe MysqLd from pid file /usr/local/MysqL/var/LNMP.pid ended
解决办法
root@LNMP var]# chmod 777 /tmp
再次启动MysqL,MysqL正常启动!
[root@LNMP var]# /etc/init.d/MysqL restart ERROR! MysqL server PID file Could not be found! Starting MysqL.. SUCCESS! [root@LNMP var]# ps -ef | grep MysqL root 5305 1 0 08:49 pts/0 00:00:00 /bin/sh /usr/local/MysqL/bin/MysqLd_safe --datadir=/usr/local/MysqL/var --pid-file=/usr/local/MysqL/var/LNMP.pid MysqL 5690 5305 1 08:49 pts/0 00:00:00 /usr/local/MysqL/bin/MysqLd --basedir=/usr/local/MysqL --datadir=/usr/local/MysqL/var --plugin-dir=/usr/local/MysqL/lib/plugin --user=MysqL --log-error=/usr/local/MysqL/var/LNMP.err --pid-file=/usr/local/MysqL/var/LNMP.pid --socket=/tmp/MysqL.sock --port=3306 root 5712 1969 0 08:49 pts/0 00:00:00 grep MysqL
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cann...
在给数据库设置用户时,
mysql> CREATE USER ''xxxx''@''localhost'' IDENTIFIED BY ''xxxx'';
Query OK, 0 rows affected (0.00 sec)//这是成功时候应出现的
结果输入第一行之后产生如题所示错误:
ERROR 1290 (HY000):
The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
上网百度解决方案:
mysql> flush privileges; //直译:更新权限
就ok了
附带mysql的操作说明:
1.使用管理员权限打开命令提示符,步骤:开始菜单选择Windows系统 - 命令提示符 - 在其上点击右键选择 - 更多 - 以管
理员身份运行。(Windows PowerShell)
PS C:\Windows\system32> net start mysql //输入这句话啊
MySQL 服务正在启动 .
MySQL 服务无法启动。
2.cd 转到自己安装mysql的路径的bin目录(试试“cd..”),比如
C:\MySQL\mysql-5.7.20-winx64\bin>
3.进入mysql(输入密码)
C:\MySQL\mysql-5.7.20-winx64\bin>mysqladmin -u root -p password
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.20
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type ''help;'' or ''\h'' for help. Type ''\c'' to clear the current input statement.
mysql>
就可以进行操作了
退出可以直接
mysql>exit
更具体的去看老师给的文档
ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot e...
今天在学习MySQL时候,想要将文本文件的数据导入到数据库中,却发现一直报错,换了导入文本的路径也还是同样的错误,错误显示ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement。
select ......into outfile 是一种逻辑备份方法,它的恢复速度非常之快,比insert的插入速度还要快。它只能备份表中的数据,并不能包含表的结构。
然后在网上找解决办法,找的方法在Linux 下也不怎么好用,最后找到了解决Linux下MySQL文件导入出错的方法
出错的原因是因为在MySQL 5.7.6版本之后,导入文件只能在secure_file_priv指定的文件夹下(也有原因是因为权限不够)
方法一:
我们可以用show variables like ''%secure%'';命令显示文件目录
这样将导入文件放在 /var/lib/mysql-files/文件夹下,之后再从这里导入就可以了
导出文件时候,也是将 文件导出到这个文件夹里。
root@localhost:mysql3306.sock [(none)]>show global variables like ''%secure%'';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| require_secure_transport | OFF |
| secure_auth | ON |
| secure_file_priv | /data/mysql/mysql3306/tmp/ |
Type ''help;'' or ''\h'' for help. Type ''\c'' to clear the current input statement.
root@localhost:mysql3306.sock [(none)]>select * from qt into outfile ''/data/mysql/mysql3306/tmp/qt.sql'';
ERROR 1046 (3D000): No database selected
root@localhost:mysql3306.sock [(none)]>select * from qq.qt into outfile ''/data/mysql/mysql3306/tmp/qt.sql''; //备份表
Query OK, 8 rows affected (0.01 sec)
[root@node1 ~]# cd /data/mysql/mysql3306/tmp/
[root@node1 tmp]# ll
total 4
-rw-rw-rw- 1 mysql mysql 56 Aug 13 06:06 qt.sql
[root@node1 tmp]# pwd
/data/mysql/mysql3306/tmp
恢复:
root@localhost:mysql3306.sock [(none)]>use qq;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
root@localhost:mysql3306.sock [qq]>select * from qt;
Empty set (0.01 sec)
root@localhost:mysql3306.sock [qq]>LOAD DATA INFILE ''/data/mysql/mysql3306/tmp/qt.sql'' into table qq qt;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''qt'' at line 1
root@localhost:mysql3306.sock [qq]>LOAD DATA INFILE ''/data/mysql/mysql3306/tmp/qt.sql'' into table qq.qt;
Query OK, 8 rows affected (0.00 sec)
Records: 8 Deleted: 0 Skipped: 0 Warnings: 0
root@localhost:mysql3306.sock [qq]>
如果显示ERROR 1261 (01000): Row 1 doesn''t contain data for all columns
这个错误,是因为数据行不匹配,默认不能有空,用下列命令解决set sql_modul = 0;
今天关于MySQL 导入 csv 文件报错 [Error Code] 1290 - The MySQL server is running with the --secure-file-priv option 解决办法的分享就到这里,希望大家有所收获,若想了解更多关于1209 -The MySQL server is running with the --read-only option、Centos6 下 Mysql启动提示 Starting MySQL. ERROR! The server quit without updating PID file、ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cann...、ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot e...等相关知识,可以在本站进行查询。
本文标签: