【Mysql】character-set-server參數

來源:互聯網
上載者:User

標籤:

分類: Linux

 

對於資料庫級的字元集,如果沒有辦法重建資料庫,可以在my.cnf檔案中使用character-set-server = utf8(要重啟資料庫服務),對於之前已經存在資料庫,此參數不產生影響。如果之前的資料庫A是latin1,在A中建立的表預設還是latin1,除非指定DEFAULT CHARSET!然而對於建立的資料庫,則繼承 my.cnf檔案中使用character-set-server = utf8! [[email protected] ~]# more /etc/my.cnf [mysqld]datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sockuser=mysqlold_passwords=1character-set-server = utf8  關閉資料庫服務,並重新啟動![[email protected] ~]# mysqladmin shutdown[[email protected] ~]# mysqld_safe &[1] 15102[[email protected] ~]# Starting mysqld daemon with databases from /var/lib/mysql[[email protected] ~]# mysqlWelcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 1Server version: 5.0.45 Source distributionType ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the buffer.mysql> show variables like ‘%server%‘;+----------------------+-----------------+| Variable_name        | Value           |+----------------------+-----------------+| character_set_server | utf8            | | collation_server     | utf8_general_ci | | server_id            | 0               | +----------------------+-----------------+3 rows in set (0.00 sec)--重建立立資料庫,查看其預設字元集:為utf8mysql> create database yql;Query OK, 1 row affected (0.00 sec)mysql> use yql;Database changed建立表的預設字元集和資料庫的預設字元集一致!mysql> create table t(id int);Query OK, 0 rows affected (0.00 sec)mysql> show create table t;+-------+-------------------------------------------------------------------------------------+| Table | Create Table                                                                        |+-------+-------------------------------------------------------------------------------------+| t     | CREATE TABLE `t` (  `id` int(11) default NULL) ENGINE=MyISAM DEFAULT CHARSET=utf8 | +-------+-------------------------------------------------------------------------------------+1 row in set (0.00 sec)mysql> show create database yql \G;  *************************** 1. row ***************************       Database: yqlCreate Database: CREATE DATABASE `yql` /*!40100 DEFAULT CHARACTER SET utf8 */1 row in set (0.00 sec)ERROR: No query specified

【Mysql】character-set-server參數

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.