MySQL修改預設編碼

來源:互聯網
上載者:User

以修改為 utf8 為例。假設你已經按照 Ubuntu下安裝 MySQL 的方法(見 ),並且安裝成功。

1. 停止 mysql

sudo /etc/init.d/mysql.server stop

2. 修改 my.cnf

sudo gedit /etc/my.cnf

找到對應部分添加紅色部分。

[client]

#mark add
default-character-set=utf8

#省略

# The MySQL server

[mysqld]

#mark add
character_set_server=utf8
#mark add
init_connect='SET NAMES utf8'

#省略

3. 啟動 mysql

sudo /etc/init.d/mysql.server start

4. 串連 mysql

mysql -u root -p

5. 檢查編碼

這裡有很多方法,樣本三種(下面 3 幅圖)。

a.  命令方式

b.  假設改變預設編碼後,你建立了資料庫 mydb 和表 mytable

注意:use mydb 之後才可以在資料庫 mydb 裡面建立表 mytable

c. \s 或者 status;

相關文章

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.