发布:2023/3/25 19:40:18作者:管理员 来源:本站 浏览次数:539
出现错误:The used command is not allowed with this MySQL version
出现错误: Loading local data is disabled; this must be enabled on both the client and server sides
解决方案:
1、需要添加配置 AllowLoadLocalInfile=true
2、如果添加了配置还报这个错 去MYSQL数据库执行:SET GLOBAL local_infile=1
我正在尝试使用mysql bulkloader类,即使我将AllowLoadLocalInfile=true添加到我的连接字符串中,也会收到以下错误。
byte[] byteArray = Encoding.ASCII.GetBytes(str1);
MemoryStream stream = new MemoryStream(byteArray);
using (MySqlConnection mConnection = new MySqlConnection("server=127.0.0.1;port=3306;database=testDB;uid=testUser;pwd=pass;AllowLoadLocalInfile=true;"))
{
MySqlBulkLoader bcp1 = new MySqlBulkLoader(mConnection);
bcp1.SourceStream = stream;
bcp1.TableName = "TableA";
bcp1.FieldTerminator = ",";
bcp1.LineTerminator = "\r\n";
bcp1.Local = true;
mConnection.Open();
bcp1.Load();
}
mysql安装根目录修改my.ini文件
[mysqld]
# 设置3306端口
port=3306
# 设置mysql的安装目录
basedir=E:\JAVA\mysql
# 设置mysql数据库的数据的存放目录
datadir=E:\JAVA\mysql\data
# 允许最大连接数
max_connections=200
# 允许连接失败的次数。这是为了防止有人从该主机试图攻击数据库系统
max_connect_errors=10
# 服务端使用的字符集默认为UTFMB4
character-set-server=utf8mb4
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
# 默认使用“mysql_native_password”插件认证
default_authentication_plugin=mysql_native_password
local_infile=1
[mysql]
local_infile=1
# 设置mysql客户端默认字符集
default-character-set=utf8mb4
[client]
local_infile=1
# 设置mysql客户端连接服务端时默认使用的端口
yte[] byteArray = Encoding.ASCII.GetBytes(str1); MemoryStream stream = new MemoryStream(byteArray); using (MySqlConnection mConnection = new MySqlConnection("server=127.0.0.1;port=3306;database=testDB;uid=testUser;pwd=pass;AllowLoadLocalInfile=true;")) { MySqlBulkLoader bcp1 = new MySqlBulkLoader(mConnection); bcp1.SourceStream = stream; bcp1.TableName = "TableA"; bcp1.FieldTerminator = ","; bcp1.LineTerminator = "\r\n"; bcp1.Local = true; mConnection.Open(); bcp1.Load(); }
© Copyright 2014 - 2024 柏港建站平台 ejk5.com. 渝ICP备16000791号-4