修改MySQL字符集
二進位制方式安裝的MySQL當時沒注意字符集問題,後來在建表的時候發現預設字符集是latin1
建個ting表
mysql> create table ting(id int);
Query OK, 0 rows affected (0.03 sec)
檢視錶的字符集
mysql> show create table ting \G
*************************** 1. row ***************************
Table: ting
Create Table: CREATE TABLE `ting` (
`id` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
1 row in set (0.00 sec)
檢視系統字符集
mysql> show variables like '%char%';
+--------------------------+-----------------------------------+
| Variable_name | Value |
+--------------------------+-----------------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /home/mysql/mysql/share/charsets/ |
+--------------------------+-----------------------------------+
8 rows in set (0.00 sec)
個性資料庫字符集
mysql> alter database test character set utf8;
Query OK, 1 row affected (0.00 sec)
再建ting1表
mysql> CREATE TABLE ting1 ( `id` int(11));
Query OK, 0 rows affected (0.01 sec)
檢視字符集
mysql> show create table ting1 \G
*************************** 1. row ***************************
Table: ting1
Create Table: CREATE TABLE `ting1` (
`id` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8
1 row in set (0.00 sec)
在my.cnf檔案中新增如下內容
[mysqld]
character_set_client= utf8
character_set_server= utf8
下次再建資料庫的時候字符集就會預設為utf8
建個ting表
mysql> create table ting(id int);
Query OK, 0 rows affected (0.03 sec)
檢視錶的字符集
mysql> show create table ting \G
*************************** 1. row ***************************
Table: ting
Create Table: CREATE TABLE `ting` (
`id` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
1 row in set (0.00 sec)
檢視系統字符集
mysql> show variables like '%char%';
+--------------------------+-----------------------------------+
| Variable_name | Value |
+--------------------------+-----------------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /home/mysql/mysql/share/charsets/ |
+--------------------------+-----------------------------------+
8 rows in set (0.00 sec)
個性資料庫字符集
mysql> alter database test character set utf8;
Query OK, 1 row affected (0.00 sec)
再建ting1表
mysql> CREATE TABLE ting1 ( `id` int(11));
Query OK, 0 rows affected (0.01 sec)
檢視字符集
mysql> show create table ting1 \G
*************************** 1. row ***************************
Table: ting1
Create Table: CREATE TABLE `ting1` (
`id` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8
1 row in set (0.00 sec)
在my.cnf檔案中新增如下內容
[mysqld]
character_set_client= utf8
character_set_server= utf8
下次再建資料庫的時候字符集就會預設為utf8
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24742969/viewspace-1959177/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- mysql 字符集修改MySql
- MySQL修改字符集MySql
- MySQL DB字符集修改方法MySql
- Ubuntu下修改mysql的字符集UbuntuMySql
- 修改mysql預設字符集的方法MySql
- mysql亂碼?一勞永逸修改mysql字符集!MySql
- MySQL檢視和修改字符集的方法MySql
- MySQL 檢視與修改預設字符集MySql
- MySQL修改表預設字符集行為MySql
- mysql學習之-字符集選定,修改。MySql
- mysql修改表、欄位、庫的字符集MySql
- MySQL修改字符集(mysqldump轉換全庫)MySql
- mysql 修改字符集為utf8mb4MySql
- 為Zabbix MySQL修改字符集排序utf8_binMySql排序
- Oracle 字符集修改Oracle
- 修改sqlserver字符集SQLServer
- 修改oracle字符集Oracle
- oracle修改字符集Oracle
- oracle字符集修改Oracle
- oracle 修改字符集Oracle
- MySQL表、欄位、庫的字符集修改方法介紹MySql
- 修改linux字符集Linux
- oracle之修改字符集Oracle
- Windows修改cmd字符集Windows
- Linux編譯安裝MySQL5.6及修改字符集Linux編譯MySql
- 怎樣修改檢視Oracle字符集及怎樣修改字符集 ztOracle
- MySQL字符集MySql
- Oracle修改資料字符集Oracle
- 修改資料庫字符集資料庫
- 修改oracle client 的字符集Oracleclient
- 修改sql server 的字符集SQLServer
- linux下mysql的預設字符集修改和預設資料庫引擎的修改LinuxMySql資料庫
- 【Mysql 學習】mysql 字符集MySql
- mysql的字符集MySql
- 修改Oracle資料庫字符集Oracle資料庫
- oracle 字符集檢視與修改Oracle
- 檢視和修改Oracle字符集Oracle
- 【轉】修改Oracle字符集(character set)Oracle