Home  >  Article  >  Database  >  rails部署中的mysql中文乱码问题

rails部署中的mysql中文乱码问题

WBOY
WBOYOriginal
2016-06-07 16:36:11910browse

最近在做一个项目,部署时想采用mysql数据库,按照常规的设置: 1,database.yml production: adapter: mysql encoding: utf8 reconnect: false database: new_park pool: 5 username: ****** password: ********* host: localhost socket: /var/run/mysqld/

最近在做一个项目,部署时想采用mysql数据库,按照常规的设置:
1,database.yml
production:
adapter: mysql
encoding: utf8
reconnect: false
database: new_park
pool: 5
username: ******
password: *********
host: localhost
socket: /var/run/mysqld/mysqld.sock

2,apache2的httpd.conf

ServerName localhost
DocumentRoot /home/sciencepark/RubyCode/NewPark/public

Allow from all

RailsEnv production
<directory>
    Options -MultiViews
</directory>

3,使用命令: rake db:setup RAILS_ENV="production"。其中seeds.rb中有中文字符。

这样之后,访问网站,出现了这样的错误: We're sorry, but something went wrong.

估计是mysql的中文问题。

网上很多帖子介绍如何解决mysql的中文乱码问题,一般是在my.cnf文件中的[client]及 [mysqld]等中添加“default-character-set=utf8”,可是我一添加,重启mysql后就出现'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'这样的错误!
去掉添加的内容后mysql可以正常启动,但中文乱码问题依旧。不知如何是好!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn