MAC configured in the mysql database encoding problem

2011-10-07  来源:本站原创  分类:Database  人气:85 

Recently installed mac osx lion system, then install the mysql5.5.16 version of the database development, but we all know, mysql's default encoding is latin1, if the store will be garbled if the Chinese, then mad google this problem, but has been are not resolved, on-line most of the answers are as follows:
1 copy / usr / local / mysql / support-files under any of the *. cnf files to / etc / my.cnf;
2 in the my.cnf file [mysqld] and [client] to append a default-character-set = utf8 (or default_character_set = utf8);
3 Save and exit;
4 Restart the mysql server you can.
But I tried many times, so that modifications, mysql service simply will not start.
By chance, I found a linux configure mysql on the coding problem, try holding the attitude, I make a change and found that really can be used, so this blog want to send a friend no longer installed mac detours up. Configuration is as follows:
1 copy / usr / local / mysql / support-files under any of the *. cnf files to / etc / my.cnf;
2 in the my.cnf file [client] to append a default-character-set = utf8 (not default_character_set = utf8 [i] [/ i], I have not tried this configuration, do not know can not be successful), the key This configuration, in the [mysqld] add the following three behind:
default-storage-engine = INNODB
character-set-server = utf8
collation-server = utf8_general_ci;
3 Save and exit;
4 Restart the mysql server you can.
Then on into the mysql database to view the code that changed utf8.
Here is my access to mysql database mysql server restart check out the results:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 520
Server version: 5.5.16 MySQL Community Server (GPL)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show variables like '%char%';
+--------------------------+--------------------------------------------------------+
| Variable_name            | Value                                                  |
+--------------------------+--------------------------------------------------------+
| character_set_client     | utf8                                                   |
| character_set_connection | utf8                                                   |
| character_set_database   | utf8                                                   |
| character_set_filesystem | binary                                                 |
| character_set_results    | utf8                                                   |
| character_set_server     | utf8                                                   |
| character_set_system     | utf8                                                   |
| character_sets_dir       | /usr/local/mysql-5.5.16-osx10.6-x86_64/share/charsets/ |
+--------------------------+--------------------------------------------------------+
8 rows in set (0.00 sec)

So far, this troubled for many days finally solved the problem.
My.cnf file with the edited content, do not know why I can not upload attachments, put the code posted Come:

# Example MySQL config file for small systems.
#
# This is for a system with little memory (<= 64M) where MySQL is only used
# from time to time and it's important that the mysqld daemon
# doesn't use much resources.
#
# MySQL programs look for option files in a set of
# locations which depend on the deployment platform.
# You can copy this option file to one of those
# locations. For information about these locations, see:
# http://dev.mysql.com/doc/mysql/en/option-files.html
#
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.

# The following options will be passed to all MySQL clients
[client]
default-character-set=utf8
#password       = your_password
port            = 3306
socket          = /tmp/mysql.sock

# Here follows entries for some specific programs

# The MySQL server
[mysqld]
default-storage-engine=INNODB
character-set-server=utf8
collation-server=utf8_general_ci
port            = 3306
socket          = /tmp/mysql.sock
skip-external-locking
key_buffer_size = 16K
max_allowed_packet = 1M
table_open_cache = 4
sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
net_buffer_length = 2K
thread_stack = 128K

# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (using the "enable-named-pipe" option) will render mysqld useless!
#
#skip-networking
server-id       = 1

# Uncomment the following if you want to log updates
#log-bin=mysql-bin

# binary logging format - mixed recommended
#binlog_format=mixed

# Causes updates to non-transactional engines using statement format to be
# written directly to binary log. Before using this option make sure that
# there are no dependencies between transactional and non-transactional
# tables such as in the statement INSERT INTO t_myisam SELECT * FROM
# t_innodb; otherwise, slaves may diverge from the master.
#binlog_direct_non_transactional_updates=TRUE

# Uncomment the following if you are using InnoDB tables
#innodb_data_home_dir = /usr/local/mysql/data
#innodb_data_file_path = ibdata1:10M:autoextend
#innodb_log_group_home_dir = /usr/local/mysql/data
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
#innodb_buffer_pool_size = 16M
#innodb_additional_mem_pool_size = 2M
# Set .._log_file_size to 25 % of buffer pool size
#innodb_log_file_size = 5M
#innodb_log_buffer_size = 8M
#innodb_flush_log_at_trx_commit = 1
#innodb_lock_wait_timeout = 50

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates

[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M

[mysqlhotcopy]
interactive-timeout
相关文章
  • MAC configured in the mysql database encoding problem 2011-10-07

    Recently installed mac osx lion system, then install the mysql5.5.16 version of the database development, but we all know, mysql's default encoding is latin1, if the store will be garbled if the Chinese, then mad google this problem, but has been are

  • Mysql database encoding problem 2010-05-25

    Coding problem: First of all consider their own application process, encoding the entire web line The following summary from different aspects of the problem set code: Set the servlet code String shuoming = new String (addrecordForm.getShuoming (). G

  • mac to modify the mysql database encoding format 2010-04-17

    First of all, you can now enter the mysql, then enter the following command show variables like 'character_set_%'; see the computer code has been installed the encoding, As for my computer: mysql> show variables like 'character_set_%'; +-------------

  • spring + hibernate + struts2 application mysql database garbage problem 2011-08-07

    In the spring configuration file to add at the end of url ? CharacterEncoding = gbk, no change. Write in the struts configuration file <constant name="struts.i18n.encoding" value="UTF-8" /> Or garbled. Finally found no change ove

  • Solve the linux environment jsp + mysql database the problem of garbled Chinese 2011-05-02

    After a week of hard work has finally solved the problem, especially the experience of an extract memo. This article will address the following types of garbage problem. Chinese data into mysql table appear garbled, mysql from JSP page to read Chines

  • Mysql database encoding 3 (modified database tables, fields encoded as utf8) 2011-05-06

    Personal recommendations, to make use of the database character set utf8 (HTML page corresponds to utf-8), so your data can achieve a very smooth move, because the utf8 character set is the most appropriate to achieve between different character sets

  • Ubuntu MySql database encoding settings 2010-05-08

    Default character set in mysql is latin1, Want to set the character set to uft-8, you can set the my.cnf file add the following: Executive: sudo gedit /etc/mysql/my.cnf Set: ·[client] default-character-set=utf8 ·[mysqld] default-character-set=utf8 sk

  • Mysql database fragmentation problem 2011-06-10

    Little bit, understand, http://database.51cto.com/art/201103/251967.htm

  • Chinese garbled mysql database problem solutions 2010-07-09

    First introduced to the situation I encounter: Action from the JSP page spread in the Chinese language is no problem, save the time it was the Chinese, save the results page is displayed in Chinese, but the database is garbled. Cause of the problem i

  • How to Enable Mac OS X system, MySQL (change) 2010-09-20

    http://www.blogjava.net/sealyu/archive/2010/05/16/321082.html With the increasing development of the network have os x users increases, there may be need in their own x-mysql + php running on the system environment, such as setting up test sites or t

  • spring + hibernate + struts2 application garbled mysql database 2011-08-07

    In the spring configuration file to add at the end of url ? CharacterEncoding = gbk, no change. Write in the struts configuration file <constant name="struts.i18n.encoding" value="UTF-8" /> Or garbled. Finally found no change ove

  • mac: php to connect mysql, error: mac PHP Warning: mysql_connect (): [2002] No such file ... 2011-04-30

    Today on the mac to connect to mysql database using php, there mac PHP Warning: mysql_connect (): [2002] No such file ... Such errors, it is easy to solve this problem: mkdir / var / mysql ln-s / tmp / mysql.sock / var / mysql / mysql.sock php in / v

  • CentOS (Linux) in MySQL5.5 database encoding settings 2011-10-09

    Environment: CentOS-5.6; MySQL5.5.15 Problem: Located on CentOS using the Java call stored procedures on MySQL, the occurrence of Chinese garbage can storage problems. Address: Start a Java application that is the connection string or a problem, goog

  • mysql database installation and construction of the table notes 2011-04-07

    When using the mysql database, there will inevitably encounter into Chinese "data too long for ....." error, set the value of this field is too small in fact not the reason, but rather is the database code and create a database instance Set enco

  • Mysql database on the character encoding 2009-02-01

    When using mysql, often because of worry about character encoding issues. In the preparation of php programs, but also often encountered in a character encoding problem. For example, in my php programming, programming environment is utf8 format, but

  • Chinese garbled mysql database problem 2010-04-20

    MYSQL database coding problems exist, the main character will be reflected in the database, garbled, WEB page display unusual character. Summed up as only one reason: there will be places where there coding coding inconsistencies. WEB Development: MY

  • MySQL database connection timeout (wait_timeout) deal with the problem 2010-12-21

    refer to: http://sarin.javaeye.com/blog/580311 Surely we will encounter when in use MySQL connection timeout problem, as shown below: Is the exception (com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure Last packet s

  • mysql database question strange ---------- the problem has been canceled!! 2010-02-07

    Just saw in the ubuntu system on the mysql database, configuration, installation tips below [email protected]:~$ sudo apt-get install mysql-server Reading package lists ... done Analyzing package dependency tree The reading state information ... d

  • Solution to connect mysql database connection pool, the every 8 hours mysql automatically disconnect problem 2010-06-18

    Solution to connect mysql database connection pool, the every 8 hours mysql automatically disconnect all connected issues Recently, a very annoying problem, our project to use their own connection pool to connect mysql database, mysql database can be

  • Remote connections Mysql database problem (ERROR 2003 (HY000)) 2010-08-12

    In our client and the remote connection with Mysql database server process, prone to the following questions: ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.0.19' (111) Mysql database for this reason that the default configuration file