mysql編碼修改
檢視mysql指定資料庫編碼
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
mysql> show create database php; +----------+-------------------------------------------------------------+ | Database | Create Database | +----------+-------------------------------------------------------------+ | php | CREATE DATABASE `php` /*!40100 DEFAULT CHARACTER SET gbk */ | +----------+-------------------------------------------------------------+ 1 row in set (0.00 sec)
mysql> show create database mysql; +----------+----------------------------------------------------------------+ | Database | Create Database | +----------+----------------------------------------------------------------+ | mysql | CREATE DATABASE `mysql` /*!40100 DEFAULT CHARACTER SET utf8 */ | +----------+----------------------------------------------------------------+ 1 row in set (0.00 sec)
|
檢視資料庫服務和客戶端字符集,mysql預設編碼是gbk的:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
mysql> status -------------- mysql Ver 14.14 Distrib 5.6.17, for Win32 (x86)
Connection id : 3
Current database: Current user: root@localhost SSL: Not in use
Using delimiter: ; Server version: 5.6.17 MySQL Community Server (GPL) Protocol version: 10 Connection: localhost via TCP /IP
Server characterset: latin1 Db characterset: latin1 Client characterset: gbk Conn. characterset: gbk TCP port: 3306 Uptime: 6 min 13 sec Threads: 1 Questions: 481 Slow queries: 0 Opens: 260 Flush tables: 1 Open t ables: 66 Queries per second avg: 1.289 -------------- |
1
2
|
mysql> set names utf8; // 臨時修改編碼,重啟資料庫還原為預設編碼
Query OK, 0 rows affected (0.00 sec) |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
mysql> status; -------------- mysql Ver 14.14 Distrib 5.6.17, for Win32 (x86)
Connection id : 1
Current database: Current user: root@localhost SSL: Not in use
Using delimiter: ; Server version: 5.6.17 MySQL Community Server (GPL) Protocol version: 10 Connection: localhost via TCP /IP
Server characterset: latin1 Db characterset: latin1 Client characterset: utf8 Conn. characterset: utf8 TCP port: 3306 Uptime: 2 min 26 sec Threads: 1 Questions: 10 Slow queries: 0 Opens: 70 Flush tables: 1 Open tab les: 63 Queries per second avg: 0.068 -------------- |
永久生效,修改my.ini檔案
[client]
#password = your_password
port = 3306
socket = /tmp/mysql.sock
default-character-set=utf8 //加上這一行,重啟mysql服務
1
2
3
4
5
|
mysql> status Server characterset: latin1 Db characterset: latin1 Client characterset: utf8 Conn. characterset: utf8 |
修改某個資料庫編碼
1
2
3
4
5
6
7
8
|
mysql> alter database res_gul character set utf8;
mysql> use res_gul mysql> status Server characterset: latin1 Db characterset: utf8 Client characterset: utf8 Conn. characterset: utf8 |
設定資料庫編碼 /etc/my.cnf
[mysqld]
default-character-set=utf8
…
[client]
default-character-set=utf8
重啟資料庫後生效
1
2
3
4
5
|
mysql> status Server characterset: utf8 Db characterset: utf8 Client characterset: utf8 Conn. characterset: utf8
|
本文轉自ling118 51CTO部落格,原文連結:http://blog.51cto.com/meiling/1625441,如需轉載請自行聯絡原作者
相關文章
- Mysql編碼, Mysql編碼流程, Mysql編碼順序, Mysql編碼原理, Mysql編碼修改依據MySql
- mysql修改資料庫編碼MySql資料庫
- MySql修改資料庫編碼為UTF8MySql資料庫
- 修改mysql資料庫的預設編碼方式MySql資料庫
- mysql 資料庫 表 欄位 編碼修改 方法MySql資料庫
- mysql 忘記密碼,mysql修改密碼MySql密碼
- mysql修改root密碼MySql密碼
- 修改mysql root密碼MySql密碼
- mysql8.0修改密碼MySql密碼
- 修改 MySQL 登入密碼MySql密碼
- mysql修改管理員密碼MySql密碼
- 修改mysql的root密碼MySql密碼
- nvme driver 原始碼修改、編譯原始碼編譯
- 批量修改檔案的編碼
- 修改Mysql root密碼的方法MySql密碼
- 修改docker中Mysql的密碼DockerMySql密碼
- Tomcat 改伺服器編碼(Java 修改字串編碼格式)Tomcat伺服器Java字串編碼
- 如何修改檔案的編碼格式
- 檢視修改mysql編碼方式讓它支援中文(gbk或者utf8)MySql
- Linux下修改MySQL資料庫字元編碼為UTF-8解決中文亂碼LinuxMySql資料庫字元
- _001_IDEA_修改編輯器的編碼Idea
- MYSQL修改密碼和忘記ROOT密碼MySql密碼
- MYSQL5.7 ROOT密碼修改教程MySql密碼
- MySQL 8.0之後版本密碼修改MySql密碼
- 修改MySQL密碼的四種方法MySql密碼
- MySQL修改密碼方法總結YRMySql密碼
- 實用小技巧! 修改MySQL密碼MySql密碼
- mysql修改使用者密碼MySql密碼
- MySQL 5.7修改忘記root密碼MySql密碼
- MySQL修改密碼方法總結 (轉)MySql密碼
- mysql密碼忘記的修改(轉)MySql密碼
- ubuntu安裝mysql後修改密碼UbuntuMySql密碼
- JPA設定MySQL編碼MySql
- 如何修改jquery的預設編碼方式jQuery
- mysql亂碼?一勞永逸修改mysql字符集!MySql
- mysql 8.0.11 以上版本修改root密碼MySql密碼
- 怎麼修改mysql的連線密碼MySql密碼
- MySQL修改賬號密碼方法大全MySql密碼