文章 "如何从 MQL5 (MQL4) 访问 MySQL 数据库" - 页 10 1...34567891011121314151617...30 新评论 1982EAcsc 2016.04.23 17:37 #91 my email: 178255721@qq.com 1982EAcsc 2016.04.23 17:54 #92 Eugeniy Lugovoy 2016.05.03 17:55 #93 1982EAcsc : Hello, it looks like MySQL deny connection for user ODBC on localhost.You can try to check StackOverflow: http://stackoverflow.com/questions/23950722/how-to-overcome-error-1045-28000-access-denied-for-user-odbclocalhost-u how to overcome ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: NO) permanently stackoverflow.com when am trying to open mysql in windows cmd by typing mysql. the following error is occuring. And then by looking similar queries i somehow got a temporary solution by using and then typing the password, is working... Jiayou Hu 2016.05.03 18:46 #94 Hi Eugeniy Lugovoy,我使用了MQLMySQL实现了常用的查询、插入、更新、删除操作,但是出现一个问题,不能插入中文,查询出来的中文也是乱码,我想问一下,你中间件封装的过程中有设置编码吗?设置的是什么编码?现象如下:DROP TABLE IF EXISTS `tb_test_pat`;CREATE TABLE `tb_test_pat` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `symbol` varchar(255) NOT NULL, `start_time` datetime NOT NULL, `end_time` datetime NOT NULL, `trend` int(10) NOT NULL, `points` int(10) unsigned zerofill NOT NULL, `comments` text CHARACTER SET utf8, PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8; 插入中文失败 Error: Query was empty query: INSERT INTO tb_test_pat (trend, symbol, start_time, end_time, points, comments) VALUES (1,'EURUSD','2014.12.16 13:00','2014.12.17 20:00',8,'测试12') 英文插入成功 Succeeded: INSERT INTO tb_test_pat (trend, symbol, start_time, end_time, points, comments) VALUES (1,'EURUSD','2014.12.16 13:00','2014.12.17 20:00',8,'abc')这是为什么? Discussion of article "How 使用数据库 - DatabasePrepare 使用数据库 - DatabaseBind Eugeniy Lugovoy 2016.05.03 20:43 #95 Jiayou Hu: Hi Eugeniy Lugovoy,我使用了MQLMySQL实现了常用的查询、插入、更新、删除操作,但是出现一个问题,不能插入中文,查询出来的中文也是乱码,我想问一下,你中间件封装的过程中有设置编码吗?设置的是什么编码?现象如下:DROP TABLE IF EXISTS `tb_test_pat`;CREATE TABLE `tb_test_pat` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `symbol` varchar(255) NOT NULL, `start_time` datetime NOT NULL, `end_time` datetime NOT NULL, `trend` int(10) NOT NULL, `points` int(10) unsigned zerofill NOT NULL, `comments` text CHARACTER SET utf8, PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8; 插入中文失败 Error: Query was empty query: INSERT INTO tb_test_pat (trend, symbol, start_time, end_time, points, comments) VALUES (1,'EURUSD','2014.12.16 13:00','2014.12.17 20:00',8,'测试12') 英文插入成功 Succeeded: INSERT INTO tb_test_pat (trend, symbol, start_time, end_time, points, comments) VALUES (1,'EURUSD','2014.12.16 13:00','2014.12.17 20:00',8,'abc')这是为什么? You can try to execute next command after MySQL connect:SET character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8'Possible some of such settings is not set to UTF. Eugeniy Lugovoy 2016.05.03 20:45 #96 Another one solution to executenext commands one-by-one after connection:SET NAMES 'utf8'SET CHARACTER SET 'utf8'SET SESSION collation_connection = 'utf8_general_ci' Jiayou Hu 2016.05.05 10:27 #97 Eugeniy Lugovoy: Another one solution to executenext commands one-by-one after connection:SET NAMES 'utf8'SET CHARACTER SET 'utf8'SET SESSION collation_connection = 'utf8_general_ci' 依然不行,不过问题我查到了bool __stdcall MySqlExecute(int pConnection, wchar_t* pQuery) { ... char Query[16384]; sprintf_s(Query, wcslen(pQuery)+10, "%S", pQuery); // 执行到这行的时候,遇到中文, Query 变成了空的字符串导致错误信息:Error: Query was empty query: UPDATE tb_test_pat SET comments='中文‘ 你能帮忙修复这个问题吗? 非常感谢!我是64位 Discussion of article "How 如何从 MQL5 (MQL4) 访问 Structure of tables: data Eugeniy Lugovoy 2016.05.05 20:55 #98 Jiayou Hu: 依然不行,不过问题我查到了bool __stdcall MySqlExecute(int pConnection, wchar_t* pQuery) { ... char Query[16384]; sprintf_s(Query, wcslen(pQuery)+10, "%S", pQuery); // 执行到这行的时候,遇到中文, Query 变成了空的字符串导致错误信息:Error: Query was empty query: UPDATE tb_test_pat SET comments='中文‘ 你能帮忙修复这个问题吗? 非常感谢!我是64位是的,“sprintf_s”和“sprintf的”不支持中国人。我会想办法帮你解决这个问题 Eugeniy Lugovoy 2016.05.05 20:57 #99 还 UTF-8 不能在这种情况下使用,但只 UTF-16 Jiayou Hu 2016.05.07 04:43 #100 Eugeniy Lugovoy: 还 UTF-8 不能在这种情况下使用,但只 UTF-16什么意思?是用UTF-16?是指设置数据库编码?还是指将中文字符串转成UTF-16? 1...34567891011121314151617...30 新评论 您错过了交易机会: 免费交易应用程序 8,000+信号可供复制 探索金融市场的经济新闻 注册 登录 拉丁字符(不带空格) 密码将被发送至该邮箱 发生错误 使用 Google 登录 您同意网站政策和使用条款 如果您没有帐号,请注册 可以使用cookies登录MQL5.com网站。 请在您的浏览器中启用必要的设置,否则您将无法登录。 忘记您的登录名/密码? 使用 Google 登录
Hello, it looks like MySQL deny connection for user ODBC on localhost.
You can try to check StackOverflow: http://stackoverflow.com/questions/23950722/how-to-overcome-error-1045-28000-access-denied-for-user-odbclocalhost-u
Hi Eugeniy Lugovoy,
我使用了MQLMySQL实现了常用的查询、插入、更新、删除操作,但是出现一个问题,不能插入中文,查询出来的中文也是乱码,我想问一下,你中间件封装的过程中有设置编码吗?设置的是什么编码?现象如下:
DROP TABLE IF EXISTS `tb_test_pat`;
CREATE TABLE `tb_test_pat` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`symbol` varchar(255) NOT NULL,
`start_time` datetime NOT NULL,
`end_time` datetime NOT NULL,
`trend` int(10) NOT NULL,
`points` int(10) unsigned zerofill NOT NULL,
`comments` text CHARACTER SET utf8,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
插入中文失败
Error: Query was empty query: INSERT INTO tb_test_pat (trend, symbol, start_time, end_time, points, comments) VALUES (1,'EURUSD','2014.12.16 13:00','2014.12.17 20:00',8,'测试12')
英文插入成功
Succeeded: INSERT INTO tb_test_pat (trend, symbol, start_time, end_time, points, comments) VALUES (1,'EURUSD','2014.12.16 13:00','2014.12.17 20:00',8,'abc')
这是为什么?
Hi Eugeniy Lugovoy,
我使用了MQLMySQL实现了常用的查询、插入、更新、删除操作,但是出现一个问题,不能插入中文,查询出来的中文也是乱码,我想问一下,你中间件封装的过程中有设置编码吗?设置的是什么编码?现象如下:
DROP TABLE IF EXISTS `tb_test_pat`;
CREATE TABLE `tb_test_pat` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`symbol` varchar(255) NOT NULL,
`start_time` datetime NOT NULL,
`end_time` datetime NOT NULL,
`trend` int(10) NOT NULL,
`points` int(10) unsigned zerofill NOT NULL,
`comments` text CHARACTER SET utf8,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
插入中文失败
Error: Query was empty query: INSERT INTO tb_test_pat (trend, symbol, start_time, end_time, points, comments) VALUES (1,'EURUSD','2014.12.16 13:00','2014.12.17 20:00',8,'测试12')
英文插入成功
Succeeded: INSERT INTO tb_test_pat (trend, symbol, start_time, end_time, points, comments) VALUES (1,'EURUSD','2014.12.16 13:00','2014.12.17 20:00',8,'abc')
这是为什么?
You can try to execute next command after MySQL connect:
SET character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8'
Possible some of such settings is not set to UTF.
Another one solution to executenext commands one-by-one after connection:
SET NAMES 'utf8'
SET CHARACTER SET 'utf8'
SET SESSION collation_connection = 'utf8_general_ci'
Another one solution to executenext commands one-by-one after connection:
SET NAMES 'utf8'
SET CHARACTER SET 'utf8'
SET SESSION collation_connection = 'utf8_general_ci'
依然不行,不过问题我查到了
bool __stdcall MySqlExecute(int pConnection, wchar_t* pQuery)
{
...
char Query[16384];
sprintf_s(Query, wcslen(pQuery)+10, "%S", pQuery); // 执行到这行的时候,遇到中文, Query 变成了空的字符串导致错误信息:Error: Query was empty query: UPDATE tb_test_pat SET comments='中文‘
你能帮忙修复这个问题吗? 非常感谢!我是64位
依然不行,不过问题我查到了
bool __stdcall MySqlExecute(int pConnection, wchar_t* pQuery)
{
...
char Query[16384];
sprintf_s(Query, wcslen(pQuery)+10, "%S", pQuery); // 执行到这行的时候,遇到中文, Query 变成了空的字符串导致错误信息:Error: Query was empty query: UPDATE tb_test_pat SET comments='中文‘
你能帮忙修复这个问题吗? 非常感谢!我是64位
还 UTF-8 不能在这种情况下使用,但只 UTF-16