Mysql Server encoding settings

Source: Internet
Author: User

After mysql is installed, the server uses lat1 encoding by default.
 
The procedure is as follows:
 
Startup method:/etc/init. d/mysql. server start
 
Effect:
 
Database changed
Mysql> status
--------------
Mysql Ver 14.12 Distrib 5.0.77, for redhat-linux-gnu (x86_64) using readline 5.1
 
Connection id: 8
Current database: demodb
Current user: root @ localhost
SSL: Not in use
Current pager: stdout
Using outfile :''
Using delimiter :;
Server version: 5.5.21 MySQL Community Server (GPL)
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: latin1
Db characterset: utf8
Client characterset: latin1
Conn. characterset: latin1
UNIX socket:/var/lib/mysql. sock
Uptime: 33 sec
 
Threads: 7 Questions: 137 Slow queries: 0 Opens: 83 Flush tables: 1 Open tables: 76 Queries per second avg: 4.151
--------------
 
Mysql>
 
 
Startup method:/etc/init. d/mysql. server start -- character-set-server = utf8
 
Effect:
Mysql> use demodb;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with-
 
Database changed
Mysql> status;
--------------
Mysql Ver 14.12 Distrib 5.0.77, for redhat-linux-gnu (x86_64) using readline 5.1
 
Connection id: 4
Current database: demodb
Current user: root @ localhost
SSL: Not in use
Current pager: stdout
Using outfile :''
Using delimiter :;
Server version: 5.5.21 MySQL Community Server (GPL)
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: utf8
Db characterset: utf8
Client characterset: latin1
Conn. characterset: latin1
UNIX socket:/var/lib/mysql. sock
Uptime: 1 min 15 sec
 
Threads: 4 Questions: 131 Slow queries: 0 Opens: 84 Flush tables: 1 Open tables: 77 Queries per second avg: 1.746
--------------
 
Mysql>
 
In this way, the encoding parameter must be specified at each startup. Otherwise, the server uses the default lat1 encoding.
 
 
Another method is:
 
Mysql> set character_set_server = utf8;
 
I also tried this method. No, but after logging on to the client again, I restored the original encoding. The reason is very simple. It is not utf8 encoding used when the system is started.
 
 
The permanent solution is to modify the configuration file.
 
# Vim/etc/my. cnf
 
The content is as follows:
[Mysqld]
Datadir =/var/lib/mysql
Socket =/var/lib/mysql. sock
User = mysql
 
# Add the following red text
Character-set-server = utf8
 
 
 
# Default to using old password format for compatibility with mysql 3.x
# Clients (those using the mysqlclient10 compatibility package ).
Old_passwords = 1
 
[Mysqld_safe]
Log-error =/var/log/mysqld. log
Pid-file =/var/run/mysqld. pid
 
 
 
| Bytes |
Copyright Notice copyright @ zhyiwww

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.