Added comments and code when using MySQL to switch to UTF8 as default encoding
git-svn-id: https://beef.googlecode.com/svn/trunk@1052 b87d56ec-f9c0-11de-8c8a-61c5e9addfc9
This commit is contained in:
12
beef
12
beef
@@ -49,7 +49,17 @@ case config.get("beef.database.default")
|
||||
when "sqlite"
|
||||
DataMapper.setup(:default, "sqlite3://#{$root_dir}/#{config.get("beef.database.sqlite.db_name")}")
|
||||
when "mysql"
|
||||
DataMapper.setup(:default, "mysql://#{config.get("beef.database.mysql.db_user")}:#{config.get("beef.database.mysql.db_passwd")}@#{config.get("beef.database.mysql.db_host")}/#{config.get("beef.database.mysql.db_name")}")
|
||||
# === Remove comment of next line for logging queries (very verbose) ===
|
||||
# DataMapper::Logger.new($stdout, :debug)
|
||||
#
|
||||
DataMapper.setup(:default,
|
||||
:adapter => 'mysql',
|
||||
:host => config.get("beef.database.mysql.db_host"),
|
||||
:username => config.get("beef.database.mysql.db_user"),
|
||||
:password => config.get("beef.database.mysql.db_passwd"),
|
||||
:database => config.get("beef.database.mysql.db_name"),
|
||||
:encoding => config.get("beef.database.mysql.db_encoding")
|
||||
)
|
||||
else
|
||||
print_error 'No default database selected. Please add one in config.yaml'
|
||||
end
|
||||
|
||||
20
config.yaml
20
config.yaml
@@ -40,20 +40,34 @@ beef:
|
||||
database:
|
||||
#supported DBs: sqlite, mysql
|
||||
|
||||
default: "sqlite"
|
||||
default: "mysql"
|
||||
# MySQL Notes:
|
||||
# It's recommended to install MySQL >= 5.5.x
|
||||
# Your system will require MySQL, MySQL-Server, MySQL-Devel and Ruby's MySQL libraries installed
|
||||
# You will also need to "sudo gem install dm-mysql-adapter"
|
||||
#
|
||||
# please note that the db should exists. Schema will be created automatically.
|
||||
# mysql> create database beef;
|
||||
# UTF8 notes. Update/Add in my.cnf (or my.ini on Win) the following. Then save and reboot MySQL.
|
||||
# Read more here: http://cameronyule.com/2008/07/configuring-mysql-to-use-utf-8
|
||||
# [mysql]
|
||||
# default-character-set=utf8
|
||||
# [mysqld]
|
||||
# character-set-server=utf8
|
||||
# collation-server=utf8_general_ci
|
||||
# init-connect='SET NAMES utf8'
|
||||
# [client]
|
||||
# default-character-set=utf8
|
||||
#
|
||||
# Please note that the db must exists. Schema will be created automatically.
|
||||
# mysql> CREATE DATABASE beef CHARACTER SET utf8 COLLATE utf8_general_ci;
|
||||
# mysql> grant all privileges on beef.* to 'beef'@'localhost' identified by 'beef123';
|
||||
#
|
||||
|
||||
mysql:
|
||||
db_host: "localhost"
|
||||
db_name: "beef"
|
||||
db_user: "beef"
|
||||
db_passwd: "beef123"
|
||||
db_encoding: "UTF-8"
|
||||
|
||||
sqlite:
|
||||
db_name: "beef.db"
|
||||
|
||||
Reference in New Issue
Block a user