标签:
1. 执行命令:
$ apt-get install mysql-server
执行上述命令会自动安装mysql-client,mysql-common等包。
2. 安装过程中会让你给root账号设置密码。
以上两步即可安装完成。
3. 配置mysql编码方式。
MySQL的配置文件默认存放在/etc/my.cnf
或者/etc/mysql/my.cnf。打开并编辑如下红色标示行。如果没有如下的红色行,添加即可。
[client] default-character-set = utf8 [mysqld] default-storage-engine = INNODB character-set-server = utf8 collation-server = utf8_general_ci
4. 查看配置是否生效。
启动mysql:
$ mysql -u root -p
Enter password:
-u 表示选择登陆的用户名, -p 表示登陆的用户密码。根据提示,输入密码即可。
进入后,输入以下命令查看编码是否都是utf8。(以下是修改之前的)
mysql> show variables like ‘%char%‘; +--------------------------+----------------------------+ | Variable_name | Value | +--------------------------+----------------------------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | latin1 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | latin1 | | character_set_system | utf8 | | character_sets_dir | /usr/share/mysql/charsets/ | +--------------------------+----------------------------+ 8 rows in set (0.00 sec)
以下是修改成功后的:
mysql> show variables like ‘%char%‘; +--------------------------+----------------------------+ | 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/ | +--------------------------+----------------------------+ 8 rows in set (0.00 sec)
如果mysql服务已经打开,编辑上述行后,不会立刻起效,重启mysql即可:service mysql restart。
标签:
原文地址:http://www.cnblogs.com/drizzlewithwind/p/5049889.html