在MySQL表中的阿拉伯文字?

我有一个小问题。 Mysql支持阿拉伯语的权利。 当我在表中存储数据,它是正常的,一切工作正常,但是当我发出一个SQL来检索数据。 我得到的阿拉伯文字为? 分数。 我已经改变了表格和列的字符集,但仍然是同样的问题。 我正在使用节点快递框架。

这里是节点与快速框架的连接文件

var mysql = require('mysql'); var db_config = { host: 'localhost', user: 'root', password: '', database: '', charset: 'utf8' }; function handleDisconnect() { connection = mysql.createConnection(db_config); // Recreate the connection, since // the old one cannot be reused. connection.connect(function(err) { // The server is either down if(err) { // or restarting (takes a while sometimes). console.log('error when connecting to db:', err); setTimeout(handleDisconnect, 2000); // We introduce a delay before attempting to reconnect, } // to avoid a hot loop, and to allow our node script to }); // process asynchronous requests in the meantime. // If you're also serving http, display a 503 error. connection.on('error', function(err) { console.log('db error', err); if(err.code === 'PROTOCOL_CONNECTION_LOST') { // Connection to the MySQL server is usually handleDisconnect(); // lost due to either server restart, or a } else { // connnection idle timeout (the wait_timeout throw err; // server variable configures this) } }); } handleDisconnect(); var sql1 = "SET CHARACTER SET utf8"; connection.query(sql1, function (err, result) { var sql = "SET SESSION collation_connection ='utf8_general_ci"; connection.query(sql, function (err, result) { }); }); 

为了整理表格的那一列,使用utf8_czech_ci 。 在数据库连接的最后使用下面的代码。 如果有类似这样的代码部分,则用下面的代码replace该部分。

 mysql_query('SET CHARACTER SET utf8')or die('charset problem:'.mysql_error()); mysql_query("SET SESSION collation_connection ='utf8_general_ci'") or die('collation problem:'.mysql_error());