ubuntu 安装mysql及修改编码

  643  netstat -tap | grep mysql
  645  apt-get install mysql-server mysql-client
  646  netstat -tap | grep mysql
  647  mysql -u root -p
  648  vim /etc/mysql/my.cnf
配置编码[增加蓝色,粗体]
[client]
default-character-set=utf8
port            = 3306
socket          = /var/run/mysqld/mysqld.sock
# Here is entries for some specific programs
# The following values assume you have at least 32M ram

# This was formally known as [safe_mysqld]. Both versions are currently parsed.
[mysqld_safe]
socket          = /var/run/mysqld/mysqld.sock
nice            = 0

[mysqld]
#
# * Basic Settings
#
character-set-server=utf8      注解:这里不能写default-character-set=utf8  否则启动mysql会报错~
user            = mysql
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
port            = 3306
basedir         = /usr
datadir         = /var/lib/mysql
tmpdir          = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking

 

查看是否更改了编码:

mysql> show variables like 'character%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | utf8          已更改为utf8  |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | utf8                       |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)

 

 


  649  /etc/init.d/mysql restart 重启
/etc/init.d/mysql start 启动
/etc/init.d/mysql shutdown --关闭mysql的命令
/etc/init.d/mysql stop --停止mysql 服务
mysql -u root -p 登陆


是否启动成功:
root@localhost:~# netstat -tap | grep mysql
tcp        0      0 localhost:mysql         *:*                     LISTEN      21795/mysqld    




 

posted on 2014-05-27 14:32  雨渐渐  阅读(211)  评论(0编辑  收藏  举报

导航