Chinaunix首页 | 论坛 | 博客
  • 博客访问: 169986
  • 博文数量: 25
  • 博客积分: 548
  • 博客等级: 中士
  • 技术积分: 229
  • 用 户 组: 普通用户
  • 注册时间: 2011-02-11 18:48
文章分类

全部博文(25)

文章存档

2012年(2)

2011年(23)

分类: LINUX

2011-10-11 11:32:42

Ubuntu10.04 mysql操作,备忘
1.基本命令
启动:sudo /etc/init.d/mysql start
停止:sudo /etc/init.d/mysql stop
重启:sudo /etc/init.d/mysql restart

2. 配置
主要配置文件位置:/etc/mysql/my.cnf.

数据库表文件夹:/var/lib/mysql/,相当于Windows下MySQL的date文件夹

登录MySQL,执行编码显示:

show variables like 'character%';
QUOTE:
+--------------------------+----------------------------+
| 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/ |
+--------------------------+----------------------------+

修改MySQL默认数据库的编码

需要编辑my.cnf文件,Windows可以直接用Mysql Server Instance Config Wizard 进行设置

sudo gedit /etc/mysql/my.cnf

找到[client] 添加:

default-character-set=utf8 //默认字符集为utf8

找到[mysqld] 添加:
QUOTE:
//默认字符集为utf8
default-character-set=utf8
//设定连接mysql数据库时使用utf8编码,以让mysql数据库为utf8运行
init_connect='SET NAMES utf8'

修改好后,重新启动mysql 即可.

查询一下show variables like 'character%';
QUOTE:
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
阅读(1910) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~