mysql修正數據庫編碼(數據庫字符集)和表的字符編碼的辦法。本站提示廣大學習愛好者:(mysql修正數據庫編碼(數據庫字符集)和表的字符編碼的辦法)文章只能為提供參考,不一定能成為您想要的結果。以下是mysql修正數據庫編碼(數據庫字符集)和表的字符編碼的辦法正文
mysql將表的字符編碼轉換成utf-8
alter table tb_anniversary convert to character set utf8;
修正數據庫mysql字符編碼為UTF8
步調1:檢查以後的字符編碼辦法
mysql> show variables like'character%';
+--------------------------+----------------------------+
|Variable_name |Value |
+--------------------------+----------------------------+
|character_set_client |latin1 |
| character_set_connection |latin1 |
| character_set_database |latin1 |
| character_set_filesystem |binary |
|character_set_results |latin1 |
|character_set_server |latin1 |
|character_set_system |utf8 |
|character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)
字符編碼為latin1時,用戶在給數據表拔出一條字符類型(char)的記載,在顯示此記載時能夠會沒法正常顯示字符類型的數據,故此處我們將mysql字符編碼修正為UTF8。操作以下:
步調2:修正my.cnf設置裝備擺設文件,修正後以下(/etc/my.cnf):
[client]
#password = your_password
port = 3306
socket = /var/lib/mysql/mysql.sock
default-character-set=utf8 #設置默許編碼為UTF8