Home > Database > Mysql Tutorial > MySQL修改默认编码

MySQL修改默认编码

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 17:15:56
Original
1042 people have browsed it

MySQL修改默认编码,以修改为 utf8 为例。假设你已经按照 Ubuntu下安装 MySQL 的方法(见 http://www.linuxidc.com/Linux/2012-03

以修改为 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.  命令方式

MySQL修改默认编码

b.  假设改变默认编码后,,你创建了数据库 mydb 和表 mytable

注意:use mydb 之后才可以在数据库 mydb 里面创建表 mytable

MySQL修改默认编码

c. \s 或者 status;

MySQL修改默认编码

linux

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template