Coder Social home page Coder Social logo

Comments (9)

fantasyni avatar fantasyni commented on July 19, 2024

node-mysql 默认字符编码是utf-8的,把数据库和表的字符集都设置成 utf-8 的就行

from bearcat-dao.

fantasyni avatar fantasyni commented on July 19, 2024
DROP TABLE IF EXISTS IDGenerator;
create table IDGenerator(
    name varchar(50) NOT NULL,
    id bigint(20) unsigned NOT NULL DEFAULT 0,

    PRIMARY KEY (name)
)ENGINE=InnoDB DEFAULT CHARSET=utf8;

创建表的时候指定下字符集

from bearcat-dao.

zyoo avatar zyoo commented on July 19, 2024

mysql设置的是utf8,可是还是乱码,我用原生的node-mysql测了一下,将charset置成Latin1 是可以正常展示的,不懂为啥啊

from bearcat-dao.

fantasyni avatar fantasyni commented on July 19, 2024

你新插入数据看看?

from bearcat-dao.

zyoo avatar zyoo commented on July 19, 2024

我们这边的数据库的charset是Latin1

from bearcat-dao.

zyoo avatar zyoo commented on July 19, 2024

坑啊,别的服务要求latin1 把我给坑了,我在mysqlConnectManager.js这个文件中加了个charset字段。。。

MysqlConnectionManager.prototype.getConnectionOptions = function() {
    var options = this.options || {}; 
    options['host'] = this.host;
    options['port'] = this.port;
    options['user'] = this.user;
    options['password'] = this.password;
    options['database'] = this.database;
    options['charset'] = this.charset; //新加的charset字段。。。
    return options
}
···

from bearcat-dao.

zyoo avatar zyoo commented on July 19, 2024

然后在context.json里面配了个charset属性。。。

from bearcat-dao.

fantasyni avatar fantasyni commented on July 19, 2024

哈哈,欢迎pull request

from bearcat-dao.

fantasyni avatar fantasyni commented on July 19, 2024

已经加了哈

from bearcat-dao.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.